home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-04d.zip / 04d / Hity z okladki / Plus Firma / AccessRT / Office1.cab / RPT2DAP.XSL < prev    next >
Extensible Markup Language  |  2003-10-09  |  111KB  |  2,576 lines

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
  3.     <ox:meta inputtype="ReportML" outputtype="DataPage" displayname="Data Access Page" visible="false" xmlns:ox="urn:schemas-microsoft-com:officexsl"/>
  4.  
  5.     <xsl:template match="/">
  6.  
  7.         <HTML xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:a="urn:schemas-microsoft-com:office:access">
  8.             <xsl:if test="RPTML/REPORT[DIR='right-to-left']">
  9.                 <xsl:attribute name="DIR">RTL</xsl:attribute>
  10.             </xsl:if>
  11.             <HEAD>
  12.                 <META name="ProgId" content="Access.Application"/>
  13.                 <META name="VBSForEventHandlers" value="true"/>
  14.                 <META http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
  15.                 <META name="DesignerVersion" content="10.00.2225"/>
  16.                 <TITLE>
  17.                     <xsl:value-of select="RPTML/REPORT[0]/CAPTION"/>
  18.                 </TITLE>
  19.                 <xsl:if test="RPTML/REPORT[0]/RECORD-SOURCE">
  20.                     <OBJECT classid="CLSID:0002E553-0000-0000-C000-000000000046" id="MSODSC" tabIndex="-1">
  21.                         <PARAM NAME="XMLData">
  22.                             <xsl:attribute name="VALUE"><xsl:eval>GetDataSourceControl(this)</xsl:eval></xsl:attribute>
  23.                             <!--<xsl:eval no-entities="true">GetDataSourceControl(this)</xsl:eval>-->
  24.                         </PARAM>
  25.                     </OBJECT>
  26.                 </xsl:if>
  27.             </HEAD>
  28.             <STYLE id="MSODAPDEFAULTS" type="text/css">
  29.                 .MSTheme-Label { BORDER-RIGHT: 0px; PADDING-RIGHT: 3px; BORDER-TOP: 0px; PADDING-LEFT: 3px; OVERFLOW: visible; BORDER-LEFT: 0px; WIDTH: 1in; BORDER-BOTTOM: 0px; HEIGHT: 0.156in; TEXT-ALIGN: left; <xsl:eval>GetLocaleFontFamily(this)</xsl:eval> }
  30.                 .MsoTextbox { PADDING-RIGHT: 3px; PADDING-LEFT: 3px; OVERFLOW: hidden; WIDTH: 1in; HEIGHT: 0.197in; <xsl:eval>GetLocaleFontFamily(this)</xsl:eval> }
  31.                 .MsoBoundSpan { BORDER-RIGHT: 0px; PADDING-RIGHT: 3px; BORDER-TOP: 0px; PADDING-LEFT: 3px; OVERFLOW: hidden; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px; TEXT-ALIGN: left; <xsl:eval>GetLocaleFontFamily(this)</xsl:eval> }
  32.                 .MsoHyperlinkDisplayText { BORDER-RIGHT: 0px; PADDING-RIGHT: 3px; BORDER-TOP: 0px; PADDING-LEFT: 3px; OVERFLOW: hidden; BORDER-LEFT: 0px; CURSOR: hand; BORDER-BOTTOM: 0px; TEXT-ALIGN: left; <xsl:eval>GetLocaleFontFamily(this)</xsl:eval> }
  33.                 .Mso2dSection { LEFT: 0px; BEHAVIOR: url(#DEFAULT#Mso2dSection); OVERFLOW: hidden; POSITION: relative; TOP: 0px; BACKGROUND-COLOR: transparent }
  34.                 .Mso2dSectionBanner { PADDING-RIGHT: 4px; DISPLAY: none; PADDING-LEFT: 4px; FONT-WEIGHT: normal; LEFT: 0px; BEHAVIOR: url(#DEFAULT#Mso2dSectionBanner); PADDING-TOP: 2px; TOP: 0px; HEIGHT: 0.2in; BACKGROUND-COLOR: buttonface; <xsl:eval>GetLocaleFontFamily(this)</xsl:eval> }
  35.                 .MsoRectangle { BORDER-RIGHT: black 1px solid; BORDER-TOP: black 1px solid; OVERFLOW: hidden; BORDER-LEFT: black 1px solid; BORDER-BOTTOM: black 1px solid }
  36.                 .MsoTitle { DISPLAY: none; FONT-WEIGHT: normal; COLOR: inactivecaptiontext }
  37.                 .MsoExpandCollapse { CURSOR: hand }
  38.                 .MsoNavContainer { BORDER-RIGHT: gainsboro 1px solid; BORDER-TOP: gainsboro 1px solid; Z-INDEX: -1; BORDER-LEFT: gainsboro 1px solid; CURSOR: hand; BORDER-BOTTOM: gainsboro 1px solid; POSITION: absolute; HEIGHT: 25px; BACKGROUND-COLOR: gainsboro}
  39.                 .MsoNavButton {    BORDER-RIGHT: gainsboro 1px solid; BORDER-TOP: gainsboro 1px solid; BORDER-LEFT: gainsboro 1px solid; CURSOR: auto; BORDER-BOTTOM: gainsboro 1px solid; BACKGROUND-REPEAT: no-repeat}                
  40.                 .MsoNavButtonMouseOver { BORDER-RIGHT: highlight 1px solid; BORDER-TOP: highlight 1px solid; BORDER-LEFT: highlight 1px solid; BORDER-BOTTOM: highlight 1px solid; BACKGROUND-COLOR: buttonhighlight}
  41.                 .MsoNavToggleButtonMouseOver { BORDER-RIGHT: highlight 1px solid; BORDER-TOP: highlight 1px solid; BORDER-LEFT: highlight 1px solid; BORDER-BOTTOM: highlight 1px solid; BACKGROUND-REPEAT: no-repeat; BACKGROUND-COLOR: buttonhighlight}
  42.                 .MsoNavButtonMouseDown { BORDER-RIGHT: buttonshadow 1px solid; BORDER-TOP: buttonshadow 1px solid; BORDER-LEFT: buttonshadow 1px solid; CURSOR: hand; BORDER-BOTTOM: buttonshadow 1px solid; BACKGROUND-COLOR: buttonshadow }
  43.                 .MsoNavRecordsetLabel { BORDER-RIGHT: gainsboro 1px solid; BORDER-TOP: gainsboro 1px solid; PADDING-LEFT: 0px; FONT-SIZE: 8pt; OVERFLOW: hidden; BORDER-LEFT: gainsboro 1px solid; WIDTH: 100%; CURSOR: default; PADDING-TOP: 0px; BORDER-BOTTOM: gainsboro 1px solid; <xsl:eval>GetLocaleFontFamily(this)</xsl:eval> }
  44.                 .MsoRecordSelector { BORDER-RIGHT: Buttonshadow 1px solid; BORDER-TOP: Buttonshadow 1px solid; OVERFLOW: hidden; BORDER-LEFT: Buttonshadow 1px solid; WIDTH: 0.17in; BORDER-BOTTOM: buttonshadow 1px solid; HEIGHT: 100%; BACKGROUND-COLOR: gainsboro}
  45.                 .MsoRecordSelectorCurrent { BACKGROUND-POSITION: 1px 0px; BACKGROUND-IMAGE: <xsl:eval>IsRightToLeft(this,"url(owc://GIF/#11240);","url(owc://GIF/#11243);")</xsl:eval> BACKGROUND-REPEAT: no-repeat }
  46.                 .MsoRecordSelectorSelectedImage { BACKGROUND-POSITION: 1px 0px; BACKGROUND-IMAGE: <xsl:eval>IsRightToLeft(this,"url(owc://GIF/#11241);","url(owc://GIF/#11244);")</xsl:eval> BACKGROUND-REPEAT: no-repeat }
  47.                 .MsoRecordSelectorSelected { BORDER-RIGHT: buttonshadow 1px solid; BORDER-TOP: buttonshadow 1px solid; LEFT: 0px; OVERFLOW: hidden; BORDER-LEFT: buttonshadow 1px solid; WIDTH: 0.17in; BORDER-BOTTOM: buttonshadow 1px solid; TOP: 0px; HEIGHT: 100%; BACKGROUND-COLOR: buttonshadow; POSTION: relative}
  48.                 .MsoRecordSelectorDirty { BACKGROUND-POSITION: -1px 0px; BACKGROUND-IMAGE: url(owc://GIF/#11242); BACKGROUND-REPEAT: no-repeat }
  49.                 .MsoRecordSelectorTransparent { LEFT: 0px; OVERFLOW: hidden; WIDTH: 0.17in; TOP: 0px; POSTION: relative }
  50.                 HR { COLOR: black }
  51.                 SELECT { <xsl:eval>GetLocaleFontFamily(this)</xsl:eval> }
  52.                 INPUT { <xsl:eval>GetLocaleFontFamily(this)</xsl:eval> }
  53.                 BODY { FONT-SIZE: 10pt; FONT-FAMILY: Tahoma }
  54.                 MARQUEE { <xsl:eval>GetLocaleFontFamily(this)</xsl:eval> }
  55.                 LEGEND { <xsl:eval>GetLocaleFontFamily(this)</xsl:eval> }
  56.                 BUTTON { <xsl:eval>GetLocaleFontFamily(this)</xsl:eval> }
  57.                 TEXTAREA { <xsl:eval>GetLocaleFontFamily(this)</xsl:eval> }
  58.             
  59.                 <xsl:choose>
  60.                     <xsl:when expr="IsDataSheet(this)">
  61.                         .MSODatasheetText { <xsl:eval>GetDatasheetStyle(this)</xsl:eval> }                    
  62.                     </xsl:when>
  63.                     <xsl:otherwise>
  64.                         <xsl:apply-templates select="/RPTML/REPORT[0]/STYLE"/>        
  65.                     </xsl:otherwise>
  66.                 </xsl:choose>
  67.             </STYLE>
  68.             <BODY>
  69.                 <xsl:attribute name="link"><xsl:eval>GetNodeText(this, "RPTML/REPORT[0]/LINK", "#0000ff")</xsl:eval></xsl:attribute>
  70.                 <xsl:attribute name="vlink"><xsl:eval>GetNodeText(this, "RPTML/REPORT[0]/VLINK", "#800080")</xsl:eval></xsl:attribute>
  71.                 <xsl:attribute name="style">OVERFLOW: auto; <xsl:eval>GetBodyStyle(this)</xsl:eval></xsl:attribute>
  72.  
  73.                 <xsl:if test="RPTML/REPORT[DIR='right-to-left']">
  74.                     <xsl:attribute name="DIR">RTL</xsl:attribute>
  75.                 </xsl:if>
  76.                 <xsl:choose>
  77.                     <xsl:when test="RPTML/REPORT[0][DEFAULT-VIEW='pivottable']">
  78.                         <OBJECT classid="CLSID:0002E552-0000-0000-C000-000000000046" id="PivotTable">
  79.                             <PARAM NAME="XMLData">
  80.                                 <xsl:attribute name="VALUE"><xsl:value-of select="RPTML/REPORT[0]/PIVOTTABLE-XML"/></xsl:attribute>
  81.                             </PARAM>
  82.                         </OBJECT>
  83.                     </xsl:when>
  84.                     <xsl:when test="RPTML/REPORT[0][DEFAULT-VIEW='pivotchart']">
  85.                         <OBJECT classid="CLSID:0002E552-0000-0000-C000-000000000046" id="PivotTable" style="width: 0; height: 0; visibility: hidden">
  86.                             <PARAM NAME="XMLData">
  87.                                 <xsl:attribute name="VALUE"><xsl:value-of select="RPTML/REPORT[0]/PIVOTTABLE-XML"/></xsl:attribute>
  88.                             </PARAM>
  89.                         </OBJECT>
  90.                         <OBJECT classid="CLSID:0002E556-0000-0000-C000-000000000046" id="PivotChart">
  91.                             <PARAM NAME="XMLData">
  92.                                 <xsl:attribute name="VALUE"><xsl:value-of select="RPTML/REPORT[0]/PIVOTCHART-XML"/></xsl:attribute>
  93.                             </PARAM>
  94.                         </OBJECT>
  95.                         <SCRIPT language="VBScript">
  96.                             Sub Window_OnLoad()
  97.                                 Set PivotChart.DataSource = PivotTable
  98.                             End Sub
  99.                         </SCRIPT>
  100.                     </xsl:when>
  101.                     <xsl:otherwise>
  102.                         <xsl:apply-templates select="RPTML/REPORT[0]"/>
  103.                     </xsl:otherwise>
  104.                 </xsl:choose>
  105.                 <xsl:if test="RPTML/REPORT[0]/CODE">
  106. <xsl:comment>
  107. ---------- BEGIN VBA CODE ----------
  108. <xsl:value-of select="RPTML/REPORT[0]/CODE"/>
  109. ----------- END VBA CODE -----------
  110. </xsl:comment>
  111.                 </xsl:if>
  112.             </BODY>
  113.         </HTML>
  114.     
  115.     </xsl:template>
  116.  
  117.     <xsl:template match="STYLE">
  118.         .<xsl:value-of select="@id"/> { <xsl:eval>GetSharedStyle(this)</xsl:eval> }
  119.     </xsl:template>
  120.  
  121.     <xsl:template match="REPORT">
  122.  
  123.         <xsl:choose>
  124.             <xsl:when expr="IsDataSheetForm(this)">
  125.             <!-- special code if default view is a data sheet -->
  126.  
  127.                 <xsl:for-each select="/RPTML/REPORT[0]/SECTION[@type='detail']">            
  128.                         <!-- header -->
  129.                         <DIV>
  130.                             <xsl:attribute name="class">Mso2dSection</xsl:attribute>
  131.                             <xsl:attribute name="id"><xsl:eval>GetCaptionID(this, "group_header")</xsl:eval></xsl:attribute>
  132.                             <xsl:attribute name="style"><xsl:eval>GetSectionPosition(this)</xsl:eval>; POSITION: relative;<xsl:eval>GetDatasheetTopBorder(this)</xsl:eval></xsl:attribute>                        
  133.                             <xsl:eval no-entities="true">GetColumnLabels(this)</xsl:eval>
  134.                         </DIV>
  135.  
  136.                         <!-- details -->
  137.                         <DIV>
  138.                             <xsl:attribute name="class">Mso2dSection</xsl:attribute>
  139.                             <xsl:attribute name="id"><xsl:eval>GetSectionID(this, "detail")</xsl:eval></xsl:attribute>
  140.                             <xsl:attribute name="style"><xsl:eval>GetSectionPosition(this)</xsl:eval>; POSITION: relative</xsl:attribute>
  141.                             <xsl:eval no-entities="true">GetColumnTextBoxes(this)</xsl:eval>
  142.                         </DIV>        
  143.  
  144.                         <!-- detail navigation section -->
  145.                         <xsl:if expr="IncludeNavigationSection(this, 'detail')">
  146.                             <DIV>
  147.                                 <xsl:attribute name="class">Mso2dSection</xsl:attribute>
  148.                                 <xsl:attribute name="id"><xsl:eval>GetSectionID(this, "detail_navigation")</xsl:eval></xsl:attribute>
  149.                                 <xsl:attribute name="style"><xsl:eval>GetDetailNavigationStyle(this)</xsl:eval></xsl:attribute>
  150.                                 <xsl:if test="/RPTML/REPORT[0]/NAVIGATION-SECTION[text()='true']">
  151.                                     <xsl:eval no-entities="true">GetDetailNavBar(this.selectSingleNode("/RPTML/REPORT"), false)</xsl:eval>
  152.                                 </xsl:if>
  153.                                 <xsl:if expr="IncludeFooterSections(this, 'detail')">
  154.                                     <xsl:apply-templates select="SECTION[@type='page_footer']"/>
  155.                                     <xsl:apply-templates select="SECTION[@type='report_footer']"/>
  156.                                 </xsl:if>
  157.                             </DIV>
  158.                         </xsl:if>
  159.                 </xsl:for-each>
  160.             
  161.             </xsl:when>
  162.             <xsl:otherwise>
  163.                 <!-- caption section -->
  164.                 <xsl:if test="SECTION[@type='report_header' or @type='page_header']">
  165.                     <DIV>
  166.                         <xsl:attribute name="class">Mso2dSection</xsl:attribute>
  167.                         <xsl:attribute name="id"><xsl:eval>GetCaptionID(this)</xsl:eval></xsl:attribute>
  168.                         <xsl:attribute name="style"><xsl:eval>GetSectionStyle(GetFirstHeaderSection(this))</xsl:eval>;<xsl:eval>GetDatasheetTopBorder(this)</xsl:eval></xsl:attribute>
  169.                         <xsl:apply-templates select="SECTION[@type='report_header']"/>
  170.                         <xsl:apply-templates select="SECTION[@type='page_header']"/>
  171.                     </DIV>
  172.                 </xsl:if>
  173.  
  174.                 <!-- group header sections -->
  175.                 <xsl:for-each select="GROUP-LEVEL[GROUP-HEADER='true']">
  176.                     <DIV>
  177.                         <xsl:attribute name="class">Mso2dSection</xsl:attribute>
  178.                         <xsl:attribute name="id"><xsl:eval>GetGroupID(this, "group_header")</xsl:eval></xsl:attribute>
  179.                         <xsl:attribute name="style"><xsl:eval>GetGroupStyle(this, "group_header")</xsl:eval></xsl:attribute>
  180.                         <xsl:eval no-entities="true">GetGroupHeaderExpando(this)</xsl:eval>
  181.                         <xsl:apply-templates select="../SECTION[@type='group_header' and @idref=context()/@id]"/>
  182.                     </DIV>
  183.                 </xsl:for-each>
  184.  
  185.                 <!-- detail section -->
  186.                 <xsl:if test="SECTION[@type='detail']">
  187.                     <DIV>
  188.                         <xsl:attribute name="class">Mso2dSection</xsl:attribute>
  189.                         <xsl:attribute name="id"><xsl:eval>GetSectionID(this, "detail")</xsl:eval></xsl:attribute>
  190.                         <xsl:attribute name="style"><xsl:eval>GetSectionStyle(this.selectSingleNode("SECTION[@type='detail']"))</xsl:eval></xsl:attribute>
  191.                         <xsl:if test="EXPANDO-TAG"><xsl:attribute name="tag"><xsl:value-of select="EXPANDO-TAG"/></xsl:attribute></xsl:if>
  192.                         <xsl:apply-templates select="SECTION[@type='detail']"/>
  193.                     </DIV>
  194.                 </xsl:if>
  195.  
  196.                 <!-- detail navigation section -->
  197.                 <xsl:if expr="IncludeNavigationSection(this, 'detail')">
  198.                     <DIV>
  199.                         <xsl:attribute name="class">Mso2dSection</xsl:attribute>
  200.                         <xsl:attribute name="id"><xsl:eval>GetSectionID(this, "detail_navigation")</xsl:eval></xsl:attribute>
  201.                         <xsl:attribute name="style"><xsl:eval>GetDetailNavigationStyle(this)</xsl:eval></xsl:attribute>
  202.                         <xsl:if test="/RPTML/REPORT[0]/NAVIGATION-SECTION[text()='true']">
  203.                             <xsl:eval no-entities="true">GetDetailNavBar(this, false)</xsl:eval>
  204.                         </xsl:if>
  205.                         <xsl:if expr="IncludeFooterSections(this, 'detail')">
  206.                             <xsl:apply-templates select="SECTION[@type='page_footer']"/>
  207.                             <xsl:apply-templates select="SECTION[@type='report_footer']"/>
  208.                         </xsl:if>
  209.                     </DIV>
  210.                 </xsl:if>
  211.  
  212.                 <!-- group footer sections -->
  213.                 <xsl:for-each select="GROUP-LEVEL">
  214.                     <xsl:if test="context()[GROUP-FOOTER='true']">
  215.                         <DIV>
  216.                             <xsl:attribute name="class">Mso2dSection</xsl:attribute>
  217.                             <xsl:attribute name="id"><xsl:eval>GetGroupID(this, "group_footer")</xsl:eval></xsl:attribute>
  218.                             <xsl:attribute name="style"><xsl:eval>GetGroupStyle(this, "group_footer")</xsl:eval></xsl:attribute>
  219.                             <xsl:apply-templates select="../SECTION[@type='group_footer' and @idref=context()/@id]"/>
  220.                         </DIV>
  221.                     </xsl:if>
  222.                     <xsl:if expr="IncludeNavigationSection(this, 'group_footer')">
  223.                         <DIV>
  224.                             <xsl:attribute name="class">Mso2dSection</xsl:attribute>
  225.                             <xsl:attribute name="id"><xsl:eval>GetGroupID(this, "group_navigation")</xsl:eval></xsl:attribute>
  226.                             <xsl:attribute name="style"><xsl:eval>GetGroupStyle(this, "group_navigation")</xsl:eval></xsl:attribute>
  227.                             <xsl:if test="/RPTML/REPORT[0]/NAVIGATION-SECTION[text()='true']">
  228.                                 <xsl:eval no-entities="true">GetGroupNavBar(this, false)</xsl:eval>
  229.                             </xsl:if>
  230.                             <xsl:if expr="IncludeFooterSections(this, 'group_footer')">
  231.                                 <xsl:apply-templates select="../SECTION[@type='page_footer']"/>
  232.                                 <xsl:apply-templates select="../SECTION[@type='report_footer']"/>
  233.                             </xsl:if>
  234.                         </DIV>
  235.                     </xsl:if>
  236.                 </xsl:for-each>
  237.             </xsl:otherwise>
  238.         </xsl:choose>
  239.     </xsl:template>
  240.  
  241.     <xsl:template match="SECTION">
  242.         <xsl:apply-templates select="REPORT-TEXT | REPORT-ITEM"/>
  243.     </xsl:template>
  244.  
  245.     <xsl:template match="REPORT-TEXT">
  246.         <xsl:if expr="IncludeReportItem(this)">
  247.             <xsl:eval no-entities="true">this.text</xsl:eval>
  248.         </xsl:if>
  249.     </xsl:template>
  250.  
  251.     <!-- NOTE: If you add more REPORT-ITEM types, update GetElementExtensions so they aren't skipped -->
  252.  
  253.     <xsl:template match="REPORT-ITEM[@type='text-box']">
  254.         <xsl:if expr="IncludeReportItem(this)">
  255.             <TEXTAREA>
  256.                 <xsl:attribute name="id"><xsl:eval>GetMungedFieldName(this)</xsl:eval></xsl:attribute>
  257.                 <xsl:attribute name="class"><xsl:eval>GetItemClass(this, "text")</xsl:eval></xsl:attribute>
  258.                 <xsl:attribute name="style"><xsl:eval>GetTextStyle(this, "text-box")</xsl:eval>; POSITION: absolute</xsl:attribute>
  259.                 <xsl:if expr="IsGeneralTextAlign(this)"><xsl:attribute name="MsoTextAlign">General</xsl:attribute></xsl:if>
  260.                 <xsl:if test="EXPANDO-TAG"><xsl:attribute name="tag"><xsl:value-of select="EXPANDO-TAG"/></xsl:attribute></xsl:if>
  261.                 <xsl:if test="context()[ENABLED='false']"><xsl:attribute name="disabled">true</xsl:attribute></xsl:if>
  262.                 <xsl:if test="context()[LOCKED='true']"><xsl:attribute name="readOnly">true</xsl:attribute></xsl:if>
  263.                 <xsl:if expr="includeTabIndex(this)"><xsl:attribute name="tabIndex"><xsl:eval>this.selectSingleNode("TAB-INDEX").text</xsl:eval></xsl:attribute></xsl:if>
  264.                 <xsl:if test="TITLE"><xsl:attribute name="title"><xsl:eval>this.selectSingleNode("TITLE").text</xsl:eval></xsl:attribute></xsl:if>
  265.                 <xsl:apply-templates />
  266.             </TEXTAREA>
  267.         </xsl:if>
  268.     </xsl:template>
  269.  
  270.     <xsl:template match="REPORT-ITEM[@type='label' and not(HREF)]">
  271.         <xsl:if expr="IncludeReportItem(this)">
  272.             <SPAN>
  273.                 <xsl:attribute name="id"><xsl:eval>GetMungedFieldName(this)</xsl:eval></xsl:attribute>
  274.                 <xsl:attribute name="class"><xsl:eval>GetItemClass(this, "label")</xsl:eval></xsl:attribute>
  275.                 <xsl:attribute name="style"><xsl:eval>GetTextStyle(this, "label")</xsl:eval>; POSITION: absolute</xsl:attribute>
  276.                 <xsl:if expr="IsGeneralTextAlign(this)"><xsl:attribute name="MsoTextAlign">General</xsl:attribute></xsl:if>
  277.                 <xsl:if test="EXPANDO-TAG"><xsl:attribute name="tag"><xsl:value-of select="EXPANDO-TAG"/></xsl:attribute></xsl:if>
  278.                 <xsl:if test="context()[ENABLED='false']"><xsl:attribute name="disabled">true</xsl:attribute></xsl:if>
  279.                 <xsl:if test="TITLE"><xsl:attribute name="title"><xsl:eval>this.selectSingleNode("TITLE").text</xsl:eval></xsl:attribute></xsl:if>
  280.                 <xsl:if test="ACCESS-KEY"><xsl:attribute name="accesskey"><xsl:eval>this.selectSingleNode("ACCESS-KEY").text</xsl:eval></xsl:attribute></xsl:if>
  281.                 <xsl:apply-templates />
  282.             </SPAN>
  283.         </xsl:if>
  284.     </xsl:template>
  285.  
  286.     <xsl:template match="REPORT-ITEM[@type='label' and HREF]">
  287.         <xsl:if expr="IncludeReportItem(this)">
  288.             <A>
  289.                 <xsl:attribute name="href"><xsl:value-of select="HREF"/></xsl:attribute>
  290.                 <xsl:attribute name="id"><xsl:eval>GetMungedFieldName(this)</xsl:eval>_Anchor</xsl:attribute>
  291.                 <SPAN>
  292.                     <xsl:attribute name="id"><xsl:eval>GetMungedFieldName(this)</xsl:eval></xsl:attribute>
  293.                     <xsl:attribute name="class"><xsl:eval>GetItemClass(this, "hyperlink")</xsl:eval></xsl:attribute>
  294.                     <xsl:attribute name="style"><xsl:eval>GetHyperlinkStyle(this)</xsl:eval>; POSITION: absolute</xsl:attribute>
  295.                     <xsl:if expr="IsGeneralTextAlign(this)"><xsl:attribute name="MsoTextAlign">General</xsl:attribute></xsl:if>
  296.                     <xsl:if test="EXPANDO-TAG"><xsl:attribute name="tag"><xsl:value-of select="EXPANDO-TAG"/></xsl:attribute></xsl:if>
  297.                     <xsl:if test="context()[ENABLED='false']"><xsl:attribute name="disabled">true</xsl:attribute></xsl:if>
  298.                     <xsl:if test="TITLE"><xsl:attribute name="title"><xsl:eval>this.selectSingleNode("TITLE").text</xsl:eval></xsl:attribute></xsl:if>
  299.                     <xsl:if test="ACCESS-KEY"><xsl:attribute name="accesskey"><xsl:eval>this.selectSingleNode("ACCESS-KEY").text</xsl:eval></xsl:attribute></xsl:if>
  300.                     <xsl:apply-templates />
  301.                 </SPAN>
  302.             </A>
  303.         </xsl:if>
  304.     </xsl:template>
  305.  
  306.     <xsl:template match="REPORT-ITEM[@type='check-box']">
  307.         <xsl:if expr="IncludeReportItem(this)">
  308.             <INPUT>
  309.                 <xsl:attribute name="id"><xsl:eval>GetMungedFieldName(this)</xsl:eval></xsl:attribute>
  310.                 <xsl:attribute name="class"><xsl:eval>GetItemClass(this, "check-box")</xsl:eval></xsl:attribute>
  311.                 <xsl:attribute name="style"><xsl:eval>GetCheckboxStyle(this)</xsl:eval>; POSITION: absolute</xsl:attribute>
  312.                 <xsl:if test="EXPANDO-TAG"><xsl:attribute name="tag"><xsl:value-of select="EXPANDO-TAG"/></xsl:attribute></xsl:if>
  313.                 <xsl:if test="context()[ENABLED='false']"><xsl:attribute name="disabled">true</xsl:attribute></xsl:if>
  314.                 <xsl:attribute name="type">checkbox</xsl:attribute>
  315.                 <xsl:if expr="includeTabIndex(this)"><xsl:attribute name="tabIndex"><xsl:eval>this.selectSingleNode("TAB-INDEX").text</xsl:eval></xsl:attribute></xsl:if>
  316.                 <xsl:if test="TITLE"><xsl:attribute name="title"><xsl:eval>this.selectSingleNode("TITLE").text</xsl:eval></xsl:attribute></xsl:if>
  317.                 <xsl:apply-templates />
  318.             </INPUT>
  319.         </xsl:if>
  320.     </xsl:template>
  321.  
  322.     <xsl:template match="REPORT-ITEM[@type='radio-button']">
  323.         <xsl:if expr="IncludeReportItem(this)">
  324.              <xsl:if expr="OrphanedRadioButton(this)">
  325.                 <INPUT>
  326.                     <xsl:attribute name="id"><xsl:eval>GetMungedFieldName(this)</xsl:eval></xsl:attribute>
  327.                     <xsl:attribute name="class"><xsl:eval>GetItemClass(this, "radio-button")</xsl:eval></xsl:attribute>
  328.                     <xsl:attribute name="style"><xsl:eval>GetBasicStyle(this)</xsl:eval>; POSITION: absolute</xsl:attribute>
  329.                     <xsl:if test="EXPANDO-TAG"><xsl:attribute name="tag"><xsl:value-of select="EXPANDO-TAG"/></xsl:attribute></xsl:if>
  330.                     <xsl:if test="context()[ENABLED='false']"><xsl:attribute name="disabled">true</xsl:attribute></xsl:if>
  331.                     <xsl:attribute name="type">radio</xsl:attribute>
  332.                     <xsl:if expr="includeTabIndex(this)"><xsl:attribute name="tabIndex"><xsl:eval>this.selectSingleNode("TAB-INDEX").text</xsl:eval></xsl:attribute></xsl:if>
  333.                     <xsl:if test="TITLE"><xsl:attribute name="title"><xsl:eval>this.selectSingleNode("TITLE").text</xsl:eval></xsl:attribute></xsl:if>
  334.                     <xsl:apply-templates />
  335.                 </INPUT>
  336.             </xsl:if>
  337.         </xsl:if>
  338.     </xsl:template>
  339.  
  340.     <xsl:template match="REPORT-ITEM[@type='line']">
  341.         <xsl:if expr="IncludeReportItem(this)">
  342.             <HR>
  343.                 <xsl:attribute name="id"><xsl:eval>GetMungedFieldName(this)</xsl:eval></xsl:attribute>
  344.                 <xsl:attribute name="class"><xsl:eval>GetItemClass(this, "line")</xsl:eval></xsl:attribute>
  345.                 <xsl:attribute name="style"><xsl:eval>GetLineStyle(this)</xsl:eval>; POSITION: absolute</xsl:attribute>
  346.                 <xsl:if test="EXPANDO-TAG"><xsl:attribute name="tag"><xsl:value-of select="EXPANDO-TAG"/></xsl:attribute></xsl:if>
  347.                 <xsl:if test="context()[ENABLED='false']"><xsl:attribute name="disabled">true</xsl:attribute></xsl:if>
  348.             </HR>
  349.         </xsl:if>
  350.     </xsl:template>
  351.  
  352.     <xsl:template match="REPORT-ITEM[@type='rectangle']">
  353.         <xsl:if expr="IncludeReportItem(this)">
  354.             <SPAN>
  355.                 <xsl:attribute name="id"><xsl:eval>GetMungedFieldName(this)</xsl:eval></xsl:attribute>
  356.                 <xsl:attribute name="class"><xsl:eval>GetItemClass(this, "rectangle")</xsl:eval></xsl:attribute>
  357.                 <xsl:attribute name="style"><xsl:eval>GetBasicStyle(this)</xsl:eval>; POSITION: absolute</xsl:attribute>
  358.                 <xsl:if test="EXPANDO-TAG"><xsl:attribute name="tag"><xsl:value-of select="EXPANDO-TAG"/></xsl:attribute></xsl:if>
  359.                 <xsl:if test="context()[ENABLED='false']"><xsl:attribute name="disabled">true</xsl:attribute></xsl:if>
  360.                 <xsl:eval no-entities="t">"&nbsp;"</xsl:eval>
  361.             </SPAN>
  362.         </xsl:if>
  363.     </xsl:template>
  364.  
  365.     <xsl:template match="REPORT-ITEM[@type='image' and not(HREF)]">
  366.         <xsl:if expr="IncludeReportItem(this)">
  367.                 <IMG>
  368.                     <xsl:attribute name="id"><xsl:eval>GetMungedFieldName(this)</xsl:eval></xsl:attribute>
  369.                     <xsl:attribute name="class"><xsl:eval>GetItemClass(this, "image")</xsl:eval></xsl:attribute>
  370.                     <xsl:attribute name="style"><xsl:eval>GetImageStyle(this)</xsl:eval>; POSITION: absolute</xsl:attribute>
  371.                     <xsl:if test="EXPANDO-TAG"><xsl:attribute name="tag"><xsl:value-of select="EXPANDO-TAG"/></xsl:attribute></xsl:if>
  372.                     <xsl:if test="context()[ENABLED='false']"><xsl:attribute name="disabled">true</xsl:attribute></xsl:if>
  373.                     <xsl:if test="SRC"><xsl:attribute name="SRC"><xsl:value-of select="SRC"/></xsl:attribute></xsl:if>
  374.                     <xsl:if test="TITLE"><xsl:attribute name="title"><xsl:eval>this.selectSingleNode("TITLE").text</xsl:eval></xsl:attribute></xsl:if>
  375.                 </IMG>
  376.         </xsl:if>
  377.     </xsl:template>
  378.  
  379.  
  380.     <xsl:template match="REPORT-ITEM[@type='image' and HREF]">
  381.         <xsl:if expr="IncludeReportItem(this)">
  382.             <A> <xsl:attribute name="href"><xsl:value-of select="HREF"/></xsl:attribute>
  383.                 <IMG>
  384.                     <xsl:attribute name="id"><xsl:eval>GetMungedFieldName(this)</xsl:eval></xsl:attribute>
  385.                     <xsl:attribute name="class"><xsl:eval>GetItemClass(this, "image")</xsl:eval></xsl:attribute>
  386.                     <xsl:attribute name="style"><xsl:eval>GetImageStyle(this)</xsl:eval>; POSITION: absolute</xsl:attribute>
  387.                     <xsl:if test="EXPANDO-TAG"><xsl:attribute name="tag"><xsl:value-of select="EXPANDO-TAG"/></xsl:attribute></xsl:if>
  388.                     <xsl:if test="context()[ENABLED='false']"><xsl:attribute name="disabled">true</xsl:attribute></xsl:if>
  389.                     <xsl:if test="SRC"><xsl:attribute name="SRC"><xsl:value-of select="SRC"/></xsl:attribute></xsl:if>
  390.                     <xsl:if test="TITLE"><xsl:attribute name="title"><xsl:eval>this.selectSingleNode("TITLE").text</xsl:eval></xsl:attribute></xsl:if>
  391.                 </IMG>
  392.             </A>
  393.         </xsl:if>
  394.     </xsl:template>
  395.  
  396.     <xsl:template match="REPORT-ITEM[@type='list-box']">
  397.         <xsl:if expr="IncludeReportItem(this)">
  398.             <xsl:choose>
  399.                 <xsl:when expr="IsReport(this)">
  400.                     <SPAN>
  401.                         <xsl:attribute name="id"><xsl:eval>GetMungedFieldName(this)</xsl:eval></xsl:attribute>
  402.                         <xsl:attribute name="class"><xsl:eval>GetItemClass(this, "list-box")</xsl:eval></xsl:attribute>
  403.                         <xsl:attribute name="style"><xsl:eval>GetBasicStyle(this)</xsl:eval>;  POSITION: absolute</xsl:attribute>
  404.                         <xsl:if expr="IsGeneralTextAlign(this)"><xsl:attribute name="MsoTextAlign">General</xsl:attribute></xsl:if>
  405.                         <xsl:if test="EXPANDO-TAG"><xsl:attribute name="tag"><xsl:value-of select="EXPANDO-TAG"/></xsl:attribute></xsl:if>
  406.                         <xsl:if test="context()[ENABLED='false']"><xsl:attribute name="disabled">true</xsl:attribute></xsl:if>
  407.                         <xsl:if expr="includeTabIndex(this)"><xsl:attribute name="tabIndex"><xsl:eval>this.selectSingleNode("TAB-INDEX").text</xsl:eval></xsl:attribute></xsl:if>
  408.                         <xsl:if test="TITLE"><xsl:attribute name="title"><xsl:eval>this.selectSingleNode("TITLE").text</xsl:eval></xsl:attribute></xsl:if>
  409.                         <xsl:apply-templates />
  410.                     </SPAN>
  411.                 </xsl:when>
  412.                 <xsl:otherwise>
  413.                     <SELECT>
  414.                         <xsl:attribute name="id"><xsl:eval>GetMungedFieldName(this)</xsl:eval></xsl:attribute>
  415.                         <xsl:attribute name="class"><xsl:eval>GetItemClass(this, "list-box")</xsl:eval></xsl:attribute>
  416.                         <xsl:attribute name="style"><xsl:eval>GetBasicStyle(this)</xsl:eval>;  POSITION: absolute</xsl:attribute>
  417.                         <xsl:if expr="IsGeneralTextAlign(this)"><xsl:attribute name="MsoTextAlign">General</xsl:attribute></xsl:if>
  418.                         <xsl:if test="EXPANDO-TAG"><xsl:attribute name="tag"><xsl:value-of select="EXPANDO-TAG"/></xsl:attribute></xsl:if>
  419.                         <xsl:if test="context()[ENABLED='false']"><xsl:attribute name="disabled">true</xsl:attribute></xsl:if>
  420.                         <xsl:attribute name="type">select-one</xsl:attribute>
  421.                         <xsl:if expr="includeTabIndex(this)"><xsl:attribute name="tabIndex"><xsl:eval>this.selectSingleNode("TAB-INDEX").text</xsl:eval></xsl:attribute></xsl:if>
  422.                         <xsl:if test="TITLE"><xsl:attribute name="title"><xsl:eval>this.selectSingleNode("TITLE").text</xsl:eval></xsl:attribute></xsl:if>
  423.                         <xsl:attribute name="size">8</xsl:attribute>
  424.                         <xsl:apply-templates />
  425.                     </SELECT>
  426.                 </xsl:otherwise>
  427.             </xsl:choose>
  428.         </xsl:if>
  429.     </xsl:template>
  430.  
  431.     <xsl:template match="REPORT-ITEM[@type='combo-box']">
  432.         <xsl:if expr="IncludeReportItem(this)">
  433.             <xsl:choose>
  434.                 <xsl:when expr="IsReport(this) || IsValueList(this)">
  435.                     <SPAN>
  436.                         <xsl:attribute name="id"><xsl:eval>GetMungedFieldName(this)</xsl:eval></xsl:attribute>
  437.                         <xsl:attribute name="class"><xsl:eval>GetItemClass(this, "combo-box")</xsl:eval></xsl:attribute>
  438.                         <xsl:attribute name="style"><xsl:eval>GetBasicStyle(this)</xsl:eval>;  POSITION: absolute</xsl:attribute>
  439.                         <xsl:if expr="IsGeneralTextAlign(this)"><xsl:attribute name="MsoTextAlign">General</xsl:attribute></xsl:if>
  440.                         <xsl:if test="EXPANDO-TAG"><xsl:attribute name="tag"><xsl:value-of select="EXPANDO-TAG"/></xsl:attribute></xsl:if>
  441.                         <xsl:if test="context()[ENABLED='false']"><xsl:attribute name="disabled">true</xsl:attribute></xsl:if>
  442.                         <xsl:if expr="includeTabIndex(this)"><xsl:attribute name="tabIndex"><xsl:eval>this.selectSingleNode("TAB-INDEX").text</xsl:eval></xsl:attribute></xsl:if>
  443.                         <xsl:if test="TITLE"><xsl:attribute name="title"><xsl:eval>this.selectSingleNode("TITLE").text</xsl:eval></xsl:attribute></xsl:if>
  444.                         <xsl:apply-templates />
  445.                     </SPAN>
  446.                 </xsl:when>
  447.                 <xsl:otherwise>
  448.                     <SELECT>
  449.                         <xsl:attribute name="id"><xsl:eval>GetMungedFieldName(this)</xsl:eval></xsl:attribute>
  450.                         <xsl:attribute name="class"><xsl:eval>GetItemClass(this, "combo-box")</xsl:eval></xsl:attribute>
  451.                         <xsl:attribute name="style"><xsl:eval>GetBasicStyle(this)</xsl:eval>;  POSITION: absolute</xsl:attribute>
  452.                         <xsl:if expr="IsGeneralTextAlign(this)"><xsl:attribute name="MsoTextAlign">General</xsl:attribute></xsl:if>
  453.                         <xsl:if test="EXPANDO-TAG"><xsl:attribute name="tag"><xsl:value-of select="EXPANDO-TAG"/></xsl:attribute></xsl:if>
  454.                         <xsl:if test="context()[ENABLED='false']"><xsl:attribute name="disabled">true</xsl:attribute></xsl:if>
  455.                         <xsl:if expr="includeTabIndex(this)"><xsl:attribute name="tabIndex"><xsl:eval>this.selectSingleNode("TAB-INDEX").text</xsl:eval></xsl:attribute></xsl:if>
  456.                         <xsl:if test="TITLE"><xsl:attribute name="title"><xsl:eval>this.selectSingleNode("TITLE").text</xsl:eval></xsl:attribute></xsl:if>
  457.                         <xsl:apply-templates />
  458.                     </SELECT>
  459.                 </xsl:otherwise>
  460.             </xsl:choose>
  461.         </xsl:if>
  462.     </xsl:template>
  463.  
  464.     <xsl:template match="REPORT-ITEM[@type='button']">
  465.         <xsl:if expr="IncludeReportItem(this)">
  466.             <BUTTON>
  467.                 <xsl:attribute name="id"><xsl:eval>GetMungedFieldName(this)</xsl:eval></xsl:attribute>
  468.                 <xsl:attribute name="class"><xsl:eval>GetItemClass(this, "button")</xsl:eval></xsl:attribute>
  469.                 <xsl:attribute name="style"><xsl:eval>GetBasicStyle(this)</xsl:eval>;  POSITION: absolute</xsl:attribute>
  470.                 <xsl:if test="EXPANDO-TAG"><xsl:attribute name="tag"><xsl:value-of select="EXPANDO-TAG"/></xsl:attribute></xsl:if>
  471.                 <xsl:if test="context()[ENABLED='false']"><xsl:attribute name="disabled">true</xsl:attribute></xsl:if>
  472.                 <xsl:if expr="includeTabIndex(this)"><xsl:attribute name="tabIndex"><xsl:eval>this.selectSingleNode("TAB-INDEX").text</xsl:eval></xsl:attribute></xsl:if>
  473.                 <xsl:if test="TITLE"><xsl:attribute name="title"><xsl:eval>this.selectSingleNode("TITLE").text</xsl:eval></xsl:attribute></xsl:if>
  474.                 <xsl:if test="ACCESS-KEY"><xsl:attribute name="accesskey"><xsl:eval>this.selectSingleNode("ACCESS-KEY").text</xsl:eval></xsl:attribute></xsl:if>
  475.                 <xsl:choose>
  476.                     <xsl:when test="SRC"><xsl:element name="IMG"><xsl:attribute name="src"><xsl:eval>this.selectSingleNode("SRC").text</xsl:eval></xsl:attribute></xsl:element></xsl:when>
  477.                     <xsl:otherwise><xsl:apply-templates /></xsl:otherwise>
  478.                 </xsl:choose>
  479.             </BUTTON>
  480.         </xsl:if>
  481.     </xsl:template>
  482.  
  483.     <xsl:template match="REPORT-ITEM[@type='option-group']">
  484.         <xsl:if expr="IncludeReportItem(this)">
  485.             <FIELDSET>
  486.                 <xsl:attribute name="id"><xsl:eval>GetMungedFieldName(this)</xsl:eval></xsl:attribute>
  487.                 <xsl:attribute name="style"><xsl:eval>GetBasicStyle(this)</xsl:eval>;  POSITION: absolute</xsl:attribute>
  488.                 <xsl:if test="EXPANDO-TAG"><xsl:attribute name="tag"><xsl:value-of select="EXPANDO-TAG"/></xsl:attribute></xsl:if>
  489.                 <xsl:if test="context()[ENABLED='false']"><xsl:attribute name="disabled">true</xsl:attribute></xsl:if>
  490.                 <xsl:if test="TITLE"><xsl:attribute name="title"><xsl:eval>this.selectSingleNode("TITLE").text</xsl:eval></xsl:attribute></xsl:if>
  491.                 <xsl:for-each select="../REPORT-ITEM[@id=context()/CHILD-LABEL]">
  492.                     <LEGEND>
  493.                         <xsl:attribute name="id"><xsl:eval>GetMungedFieldName(GetParentOptionGroup(this))</xsl:eval>_Legend</xsl:attribute>
  494.                         <xsl:attribute name="class"><xsl:eval>GetItemClass(this, "label")</xsl:eval></xsl:attribute>
  495.                         <xsl:attribute name="style"><xsl:eval>GetTextStyle(this, "option-group")</xsl:eval></xsl:attribute>
  496.                         <xsl:if test="EXPANDO-TAG"><xsl:attribute name="tag"><xsl:value-of select="EXPANDO-TAG"/></xsl:attribute></xsl:if>
  497.                         <xsl:if test="context()[ENABLED='false']"><xsl:attribute name="disabled">true</xsl:attribute></xsl:if>
  498.                         <xsl:eval>this.selectSingleNode("CAPTION").text</xsl:eval>
  499.                         <xsl:if test="TITLE"><xsl:attribute name="title"><xsl:eval>this.selectSingleNode("TITLE").text</xsl:eval></xsl:attribute></xsl:if>
  500.                     </LEGEND>
  501.                 </xsl:for-each>
  502.                 <xsl:for-each select="../REPORT-ITEM[(@type='radio-button' or @type='check-box') and @parent=context()/@id]">
  503.                     <INPUT>
  504.                         <xsl:attribute name="id"><xsl:eval>GetMungedFieldName(this)</xsl:eval>_Option</xsl:attribute>
  505.                         <xsl:attribute name="style"><xsl:eval>GetRadioButtonStyle(this)</xsl:eval>; POSITION: absolute</xsl:attribute>
  506.                         <xsl:if test="EXPANDO-TAG"><xsl:attribute name="tag"><xsl:value-of select="EXPANDO-TAG"/></xsl:attribute></xsl:if>
  507.                         <xsl:if test="context()[ENABLED='false']"><xsl:attribute name="disabled">true</xsl:attribute></xsl:if>
  508.                         <xsl:attribute name="type">radio</xsl:attribute>
  509.                         <xsl:attribute name="value"><xsl:eval>this.selectSingleNode("VALUE").text</xsl:eval></xsl:attribute>
  510.                         <xsl:attribute name="name"><xsl:eval>this.selectSingleNode("@parent").text + "___Option___"</xsl:eval></xsl:attribute>
  511.                         <xsl:if test="TITLE"><xsl:attribute name="title"><xsl:eval>this.selectSingleNode("TITLE").text</xsl:eval></xsl:attribute></xsl:if>
  512.                     </INPUT>
  513.                     <xsl:for-each select="../REPORT-ITEM[@type='label' and @parent=context()/@id]">
  514.                         <SPAN>
  515.                             <xsl:attribute name="id"><xsl:eval>GetMungedFieldName(this)</xsl:eval></xsl:attribute>
  516.                             <xsl:attribute name="class"><xsl:eval>GetItemClass(this, "label")</xsl:eval></xsl:attribute>
  517.                             <xsl:attribute name="style"><xsl:eval>GetTextStyle(this, "option-group")</xsl:eval>; POSITION: absolute</xsl:attribute>
  518.                             <xsl:if test="EXPANDO-TAG"><xsl:attribute name="tag"><xsl:value-of select="EXPANDO-TAG"/></xsl:attribute></xsl:if>
  519.                             <xsl:if test="context()[ENABLED='false']"><xsl:attribute name="disabled">true</xsl:attribute></xsl:if>
  520.                             <xsl:if test="TITLE"><xsl:attribute name="title"><xsl:eval>this.selectSingleNode("TITLE").text</xsl:eval></xsl:attribute></xsl:if>
  521.                             <xsl:apply-templates />
  522.                         </SPAN>
  523.                     </xsl:for-each>
  524.                 </xsl:for-each>
  525.             </FIELDSET>
  526.         </xsl:if>
  527.     </xsl:template>
  528.  
  529.     <!-- NOTE: If you add more REPORT-ITEM types, update GetElementExtensions so they aren't skipped -->
  530.  
  531.     <xsl:template match="CAPTION">
  532.         <xsl:choose>
  533.             <xsl:when test="../ACCESS-KEY"><xsl:eval no-entities="true">GetAccessKey(this)</xsl:eval></xsl:when>
  534.             <xsl:otherwise>
  535.                 <xsl:value-of select="."/>
  536.             </xsl:otherwise>
  537.         </xsl:choose>
  538.     </xsl:template>
  539.  
  540.     <xsl:script><![CDATA[
  541.  
  542.         //
  543.         // Get the top-level DSC persistence
  544.         //
  545.         function GetDataSourceControl(objElem)
  546.             {
  547.             // This will be true if this a standard DataPage with multiple controls and false if it is a PivotList or PivotChart view
  548.             var fComplexPage = true;
  549.  
  550.             var objViewOnOpen = objElem.selectSingleNode("/RPTML/REPORT[0]/DEFAULT-VIEW");
  551.             if (objViewOnOpen != null && (objViewOnOpen.text == "pivottable" || objViewOnOpen.text == "pivotchart"))
  552.                 fComplexPage = false;
  553.  
  554.             return    '<xml xmlns:a="urn:schemas-microsoft-com:office:access">\r\n' +
  555.                         '<a:DataSourceControl>\r\n' +
  556.                             GetDataSourceControlProperties(objElem, fComplexPage) +
  557.                             (fComplexPage ? GetElementExtensions(objElem) : GetControlElementExtension(objViewOnOpen.text)) +
  558.                             (fComplexPage ? GetGroupLevels(objElem, fComplexPage) : '') +
  559.                             GetDataModel(objElem, fComplexPage) +
  560.                         '</a:DataSourceControl>\r\n' +
  561.                     '</xml>';
  562.             }
  563.  
  564.         //
  565.         // Get the DSC persistence properties
  566.         //
  567.         function GetDataSourceControlProperties(objElem, fComplexPage)
  568.             {
  569.             var fDataEntry       = (GetNodeText(objElem, "/RPTML/REPORT[0]/DATA-ENTRY", "") == 'true');
  570.             var nGridX = GetNodeText(objElem, "/RPTML/REPORT[0]/GRID-X", "24");
  571.             var nGridY = GetNodeText(objElem, "/RPTML/REPORT[0]/GRID-Y", "24");
  572.  
  573.             return    '<a:OWCVersion>10.0.0.1402 (OFFSEN1,DEBUG)</a:OWCVersion>\r\n' +
  574.                     '<a:ConnectionString>' + objElem.selectSingleNode("/RPTML/REPORT[0]/CONNECTION-STRING").text + '</a:ConnectionString>\r\n' +
  575.                     (fDataEntry ? '<a:DataEntry/>\r\n' : '') +
  576.                     '<a:MaxRecords>10000</a:MaxRecords>\r\n' +
  577.                     (fComplexPage ? '' : '<a:DefaultRecordsetName>' + CleanFormReferences(objElem.selectSingleNode("/RPTML/REPORT[0]/RECORD-SOURCE").text, objElem) + '</a:DefaultRecordsetName>\r\n') +
  578.                     '<a:GridX>' + nGridX + '</a:GridX>\r\n' +
  579.                     '<a:GridY>' + nGridY + '</a:GridY>\r\n' +
  580.                     '<a:OfflineType>2</a:OfflineType>\r\n' +
  581.                     '<a:OfflinePublication/>\r\n' +
  582.                     '<a:XMLLocation>0</a:XMLLocation>\r\n' +
  583.                     '<a:XMLDataTarget/>\r\n' +
  584.                     '<a:ConnectionFile/>\r\n';
  585.             }
  586.  
  587.         //
  588.         // Get all element extensions
  589.         //
  590.         function GetElementExtensions(objElem)
  591.             {
  592.             var strList = "";
  593.             var strSource = "";
  594.             var objNodes;
  595.  
  596.             // We allow binding of controls in all sections of a form but not in certain sections of a report
  597.             if (objElem.selectSingleNode("/RPTML/REPORT[0]/OBJECT-TYPE").text == "form")
  598.                 objNodes = objElem.selectNodes("/RPTML/REPORT[0]/SECTION/REPORT-ITEM[CONTROL-SOURCE]");
  599.             else
  600.                 objNodes = objElem.selectNodes("/RPTML/REPORT[0]/SECTION[@type!='report_header' and @type!='page_header' and @type!='page_footer' and @type!='report_footer']/REPORT-ITEM[CONTROL-SOURCE]");
  601.  
  602.             // Walk through the list of retrieved nodes
  603.             for (var iNode = 0; iNode < objNodes.length; iNode++)
  604.                 {
  605.                 objNode = objNodes.item(iNode);
  606.  
  607.                 // Check if we should bind this item
  608.                 if (!IncludeReportItem(objNode) && !IsDataSheetForm(objNode))
  609.                     continue;
  610.  
  611.                 // List the valid bound types. Anything not listed here will remain unbound.
  612.  
  613.                 var strType = GetNodeText(objNode, "@type", "");
  614.                 switch (strType)
  615.                     {
  616.                     case "text-box":
  617.                     case "label":
  618.                     case "check-box":
  619.                     case "list-box":
  620.                     case "combo-box":
  621.                     case "button":
  622.                     case "option-group":
  623.                         break;
  624.                     default:
  625.                         continue;
  626.                     }
  627.  
  628.                 var strChildLabel = '';
  629.                 if ((objNode.selectSingleNode("CHILD-LABEL") != null) && !IsDataSheetForm(objNode)) 
  630.                     strChildLabel = '<a:ChildLabel>' + objNode.selectSingleNode("CHILD-LABEL").text + '</a:ChildLabel>\r\n';
  631.                 var strDefaultValue = (objNode.selectSingleNode("DEFAULT-VALUE") != null ? '<a:DefaultValue>' + CleanFormReferences(StripQuotes(objNode.selectSingleNode("DEFAULT-VALUE").text)) + '</a:DefaultValue>\r\n' : '');
  632.                 var strFormat = '';
  633.                 
  634.                 var objFormat = objNode.selectSingleNode("FORMAT");
  635.                 if (objFormat != null)
  636.                     {
  637.                     strFormat = '<a:Format>';
  638.                     switch (objFormat.text)
  639.                         {
  640.                         case "Currency":
  641.                             strFormat += 'Local Currency';
  642.                             break;
  643.                         
  644.                         case "Euro":
  645.                             strFormat += 'Euro Currency';
  646.                             break;
  647.                         
  648.                         default:
  649.                             strFormat += objNode.selectSingleNode("FORMAT").text;
  650.                             break;
  651.                         }
  652.  
  653.                     strFormat += '</a:Format>\r\n';
  654.                     }
  655.  
  656.                 // List-boxes and combo-boxes require special handling in the element extension list
  657.                 switch (objNode.selectSingleNode("@type").text)
  658.                     {
  659.                     case "list-box":
  660.                     case "combo-box":
  661.                         var objRowsourceType = objNode.selectSingleNode("ROW-SOURCE-TYPE");
  662.                         if (objRowsourceType != null && objRowsourceType.text != "Value List")
  663.                         {
  664.                             var objRowsource = objElem.selectSingleNode("/RPTML/REPORT[0]/DATA-MODEL/ROW-SOURCE[@id='" + objNode.selectSingleNode("ROW-SOURCE").text + "']");
  665.                             var objFields = objRowsource.selectNodes("FIELD");
  666.                             var objListBoundField = objFields.item(objNode.selectSingleNode("BOUND-COLUMN").text - 1);
  667.                             var nListDisplayField = GetListDisplayFieldNum(objNode);
  668.  
  669.                             var strListDisplayField = "";
  670.                             if (nListDisplayField)
  671.                                 {
  672.                                 var objListDisplayField = objFields.item(nListDisplayField);
  673.                                 if (objListDisplayField != null)
  674.                                     {
  675.                                     strListDisplayField = GetNodeText(objListDisplayField, "@id", "");
  676.                                     }
  677.                                 else
  678.                                     {
  679.                                     nListDisplayField = 0;
  680.                                     }
  681.                                 }
  682.                         
  683.                             strList = strList +
  684.                                 '<a:ElementExtension>\r\n' +
  685.                                     '<a:ElementID>' + GetMungedFieldName(objNode) + '</a:ElementID>\r\n' +
  686.                                     '<a:ListRowSource>' + CleanFormReferences(objNode.selectSingleNode("ROW-SOURCE").text, objNode) + '</a:ListRowSource>\r\n' +
  687.                                     '<a:ListBoundField>' + objListBoundField.selectSingleNode("@id").text + '</a:ListBoundField>\r\n' +
  688.                                     (nListDisplayField ? '<a:ListDisplayField>' + strListDisplayField + '</a:ListDisplayField>\r\n' : '') +
  689.                                     (IncludeControlSource(objNode) ? '<a:ControlSource>' + objNode.selectSingleNode("CONTROL-SOURCE").text + '</a:ControlSource>\r\n' : '') +
  690.                                     strChildLabel +
  691.                                     strDefaultValue +
  692.                                     strFormat +
  693.                                 '</a:ElementExtension>\r\n';
  694.                             break;
  695.                         } // treat value lists as text boxes, don't break
  696.                     default:
  697.                         var objGL;
  698.                         var objSection;
  699.                         var strGroupOf = '';
  700.                         var strAbsGL = '';
  701.                         
  702.                         // Rename the field if it is in a section that has a GroupLevel
  703.                         objSection = objNode.selectSingleNode("../@idref");
  704.                         if (objSection != null)
  705.                             {
  706.                             strGroupOf = 'GroupOf';
  707.                             objGL = objElem.selectSingleNode("/RPTML/REPORT[0]/GROUP-LEVEL[@id='" + objSection.text + "']")
  708.                             if (objGL != null)
  709.                                 strAbsGL = absoluteChildNumber(objGL);
  710.                             }
  711.  
  712.                         if (GetNodeText(objNode, "CONTROL-SOURCE/@type", "") == "expression")
  713.                             strSource = GetMungedFieldName(objNode);
  714.                         else
  715.                             strSource = MungeFieldName(objNode.selectSingleNode("CONTROL-SOURCE").text);
  716.  
  717.                         strList = strList +
  718.                             '<a:ElementExtension>\r\n' +
  719.                                 '<a:ElementID>' + GetMungedFieldName(objNode) + '</a:ElementID>\r\n' +
  720.                                 (IncludeControlSource(objNode) ? '<a:ControlSource>' + strGroupOf + strSource + strAbsGL + '</a:ControlSource>\r\n' : '') +
  721.                                 strChildLabel +
  722.                                 strDefaultValue +
  723.                                 strFormat +
  724.                             '</a:ElementExtension>\r\n';
  725.                     }
  726.  
  727.                     // add element extensions for child controls
  728.                     if (objNode.selectSingleNode("@type").text == "option-group")
  729.                         {
  730.                         var objChildren = objNode.selectNodes("CHILD-CONTROLS/CHILD-CONTROL")
  731.                         var objChild;
  732.                         var objChildControl;
  733.                         for (var iChild = 0; iChild < objChildren.length; iChild++)
  734.                             {
  735.                             objChild = objChildren.item(iChild);
  736.                             objChildControl = objChild.selectSingleNode("/RPTML/REPORT[0]/SECTION/REPORT-ITEM[@id='" + objChild.text + "']");
  737.                             if (objChildControl != null && objChildControl.selectSingleNode("CONTROL-SOURCE") == null)
  738.                                 {
  739.                                 strChildLabel   = (objChildControl.selectSingleNode("CHILD-LABEL") != null ? '<a:ChildLabel>' + objChildControl.selectSingleNode("CHILD-LABEL").text + '</a:ChildLabel>\r\n' : '');
  740.                                 strList = strList +
  741.                                         '<a:ElementExtension>\r\n' +
  742.                                         '<a:ElementID>' + GetMungedFieldName(objChildControl) + '_Option</a:ElementID>\r\n' +
  743.                                         strChildLabel +
  744.                                         '</a:ElementExtension>\r\n'; 
  745.                                 }
  746.                             }
  747.                         }
  748.                 }
  749.  
  750.             // If we have navbars, add the appropriate element extensions
  751.             if (IncludeNavigationBar(objElem))
  752.                 {
  753.                 strSource = CleanFormReferences(objElem.selectSingleNode("/RPTML/REPORT[0]/RECORD-SOURCE").text, objElem);
  754.  
  755.                 objLevels = objElem.selectNodes("/RPTML/REPORT[0]/GROUP-LEVEL");
  756.                 var objLevel
  757.                 for (var iLevel = 0; iLevel < objLevels.length; iLevel++)
  758.                     {
  759.                     objLevel = objLevels.item(iLevel);
  760.                     if (objLevel.selectSingleNode("GROUP-HEADER").text == "true" || objLevel.selectSingleNode("GROUP-FOOTER").text == "true")
  761.                         {
  762.                         var strGLSource = GetNodeText(objLevel, "@id", "");
  763.  
  764.                         // One for each group-header or group-footer
  765.                         strList = strList +
  766.                             '<a:ElementExtension>\r\n' +
  767.                                 '<a:ElementID>' + CleanFormReferences(strGLSource, objLevel) + 'NavLabel</a:ElementID>\r\n' +
  768.                                 '<a:RecordsetLabel>' + strGLSource + ' |0 of |2;' + strGLSource + ' |0-|1 of |2</a:RecordsetLabel>\r\n' + 
  769.                                 '<a:ConsumesRecordset/>\r\n' +
  770.                             '</a:ElementExtension>\r\n';
  771.                         }
  772.                     }
  773.  
  774.                 // One for the main detail section
  775.                 strList = strList +
  776.                     '<a:ElementExtension>\r\n' +
  777.                         '<a:ElementID>' + CleanFormReferences(strSource, objElem) + 'NavLabel</a:ElementID>\r\n' +
  778.                         '<a:RecordsetLabel>' + strSource + ' |0 of |2;' + strSource + ' |0-|1 of |2</a:RecordsetLabel>\r\n' + 
  779.                         '<a:ConsumesRecordset/>\r\n' +
  780.                     '</a:ElementExtension>\r\n';
  781.                 }
  782.  
  783.             return strList;
  784.             }
  785.  
  786.         //
  787.         // Get the element extensions for the PivotTable or PivotChart view
  788.         //
  789.         function GetControlElementExtension(strControl)
  790.             {
  791.             return    '<a:ElementExtension>\r\n' +
  792.                         '<a:ElementID>PivotTable</a:ElementID>\r\n' +    // We always bind the PivotTable, even with a PivotChart
  793.                         '<a:ConsumesRecordset/>\r\n' +
  794.                     '</a:ElementExtension>\r\n';
  795.             }
  796.  
  797.         //
  798.         // Get the properties for each group-level
  799.         //
  800.         function GetGroupLevels(objElem)
  801.             {
  802.             var strGroupLevels = '';
  803.             var strDefaultSort = '';
  804.             var strSource = CleanFormReferences(objElem.selectSingleNode("/RPTML/REPORT[0]/RECORD-SOURCE").text, objElem);
  805.             var strDataPageSize = "1";
  806.  
  807.             var strObjectType = objElem.selectSingleNode("/RPTML/REPORT[0]/OBJECT-TYPE").text;
  808.             if (strObjectType == "table" || strObjectType == "report" || IsDataSheetForm(objElem))
  809.                 if (IsDataSheet(objElem) && !IncludeNavigationBar(objElem))
  810.                     strDataPageSize = "-1";
  811.                 else
  812.                     strDataPageSize = "10";            // Table and report views show 10 records
  813.             else
  814.                 {
  815.                 var objView = objElem.selectSingleNode("/RPTML/REPORT[0]/DEFAULT-VIEW");
  816.                 if (objView != null && objView.text == "continuous-forms")
  817.                     strDataPageSize = "-1";        // Continuous form shows all records
  818.                 else
  819.                     strDataPageSize = "1";        // Regular form shows single record
  820.                 }
  821.  
  822.             var fNavigationBar  = IncludeNavigationBar(objElem);
  823.  
  824.             var fReadOnly        = IsReport(objElem);
  825.             var fAllowEdits     = !fReadOnly && (GetNodeText(objElem, "/RPTML/REPORT[0]/ALLOW-EDITS", "true") == "true");
  826.             var fAllowAdditions = !fReadOnly && (GetNodeText(objElem, "/RPTML/REPORT[0]/ALLOW-ADDITIONS", "true") == "true");
  827.             var fAllowDeletions = !fReadOnly && (GetNodeText(objElem, "/RPTML/REPORT[0]/ALLOW-DELETIONS", "true") == "true");
  828.             var fRecordSelector = !fReadOnly && (GetNodeText(objElem, "/RPTML/REPORT[0]/OBJECT-TYPE", "") == "form" && GetNodeText(objElem, "/RPTML/REPORT[0]/RECORD-SELECTORS", "") == "true");
  829.             fRecordSelector = fRecordSelector || IsDataSheet(objElem) || IsDataSheetForm(objElem);
  830.  
  831.             var objLevels = objElem.selectNodes("/RPTML/REPORT[0]/GROUP-LEVEL");
  832.             var objLevel;
  833.             var strSortDirection;
  834.             var strSourceName;
  835.             var fHeaderElement;
  836.             var fFooterElement;
  837.             var fCaptionElement;
  838.             var fNavigationElement;
  839.             for (var iLevel = 0; iLevel < objLevels.length; iLevel++)
  840.                 {
  841.                 objLevel = objLevels.item(iLevel);
  842.                 if (objLevel.selectSingleNode("GROUP-HEADER").text == "true" || objLevel.selectSingleNode("GROUP-FOOTER").text == "true")
  843.                     {
  844.                     strSortDirection = (GetNodeText(objLevel, "SORT-ORDER", "ascending") == "ascending" ? " ASC" : " DESC");
  845.                     strSourceName = objLevel.selectSingleNode("CONTROL-SOURCE").text;
  846.  
  847.                     fHeaderElement     = (GetNodeText(objLevel, "GROUP-HEADER", "") == "true");
  848.                     fFooterElement     = (GetNodeText(objLevel, "GROUP-FOOTER", "") == "true");
  849.                     fCaptionElement    = (iLevel == 0 && objElem.selectSingleNode("/RPTML/REPORT[0]/SECTION[@type='report_header' or @type='page_header']") != null)
  850.                     fNavigationElement = (fNavigationBar || (!IsDataSheet(objElem) && iLevel == objLevels.length - 1 && GetFirstFooterSection(objElem) != null));
  851.  
  852.                     // GroupLevel element for each GROUP-LEVEL in the ReportML
  853.                     strGroupLevels = strGroupLevels +
  854.                         '<a:GroupLevel>\r\n' +
  855.                             '<a:RecordSource>' + CleanFormReferences(objLevel.selectSingleNode("@id").text, objLevel) + '</a:RecordSource>\r\n' +
  856.                             '<a:DefaultSort>' + GetDefaultSort(objLevel, true, true) + strSortDirection + '</a:DefaultSort>\r\n' +
  857.                             (fHeaderElement ? '<a:HeaderElementId>Header' + CleanFormReferences(objLevel.selectSingleNode("@id").text, objLevel) + '</a:HeaderElementId>\r\n' : '') +
  858.                             (fFooterElement ? '<a:FooterElementId>Footer' + CleanFormReferences(objLevel.selectSingleNode("@id").text, objLevel) + '</a:FooterElementId>\r\n' : '') +
  859.                             (fCaptionElement ? '<a:CaptionElementId>Caption' + CleanFormReferences(objLevel.selectSingleNode("@id").text, objLevel) + '</a:CaptionElementId>\r\n' : '') +
  860.                             (fNavigationElement ? '<a:RecordNavigationElementId>Navigation' + CleanFormReferences(objLevel.selectSingleNode("@id").text, objLevel) + '</a:RecordNavigationElementId>\r\n' : '') +
  861.                             '<a:DataPageSize>' + strDataPageSize + '</a:DataPageSize>\r\n' +
  862.                             '<a:GroupFilterControl/>\r\n' +
  863.                             (fAllowEdits     ? '' : '<a:NoAllowEdits/>\r\n') +
  864.                             (fAllowAdditions ? '' : '<a:NoAllowAdditions/>\r\n') +
  865.                             (fAllowDeletions ? '' : '<a:NoAllowDeletions/>\r\n') +
  866.                             (fRecordSelector ? '<a:RecordSelector/>\r\n' : '') +
  867.                         '</a:GroupLevel>\r\n';
  868.                     }
  869.                 else // not a real group level, just get the sort
  870.                     {
  871.                     strSourceName = GetDefaultSort(objLevel, false, false);
  872.                     strSortDirection = (GetNodeText(objLevel, "SORT-ORDER", "ascending") == "ascending" ? " ASC" : " DESC");
  873.                     if (strDefaultSort.length > 0)
  874.                         {
  875.                         strDefaultSort += ', ' + strSourceName + strSortDirection;
  876.                         }
  877.                     else
  878.                         {
  879.                         strDefaultSort = strSourceName + strSortDirection;
  880.                         }
  881.                     }
  882.                 }
  883.             objLevel = objLevels.item(0);
  884.  
  885.             // if we still don't have a default sort
  886.             if (strDefaultSort == "")
  887.                 {
  888.                 if (GetNodeText(objElem, "/RPTML/REPORT[0]/DEFAULT-SORT-ON", "") == "true")
  889.                     {
  890.                     strDefaultSort = StripTableNames(GetNodeText(objElem, "/RPTML/REPORT[0]/DEFAULT-SORT", ""));
  891.                     if (strDefaultSort == "false")
  892.                         strDefaultSort = "";
  893.                     }
  894.                 else 
  895.                     {
  896.                     if (objLevel != null && strDefaultSort.length == 0)
  897.                         {
  898.                         strSourceName = GetDefaultSort(objLevel, false, false);
  899.                         strSortDirection = (GetNodeText(objLevel, "SORT-ORDER", "ascending") == "ascending" ? " ASC" : " DESC");
  900.                         strDefaultSort = strSourceName + strSortDirection;
  901.                         }
  902.                     }
  903.                 }
  904.         
  905.             fCaptionElement    = (objLevels.length == 0 && GetFirstHeaderSection(objElem) != null) || IsDataSheetForm(objElem);
  906.             fNavigationElement = (fNavigationBar || (!IsDataSheet(objElem) && objElem.selectNodes("/RPTML/REPORT[0]/GROUP-LEVEL[GROUP-FOOTER='true']").length == 0 && GetFirstFooterSection(objElem) != null));
  907.  
  908.             // GroupLevel for the main detail section
  909.             strGroupLevels = strGroupLevels +
  910.                 '<a:GroupLevel>\r\n' +
  911.                     '<a:RecordSource>' + strSource + '</a:RecordSource>\r\n' +
  912.                     '<a:DefaultSort>' + strDefaultSort + '</a:DefaultSort>\r\n' +
  913.                     '<a:HeaderElementId>Header' + strSource + '</a:HeaderElementId>\r\n' +
  914.                     '<a:FooterelementId/>\r\n' +
  915.                     (fCaptionElement ? '<a:CaptionElementId>Caption' + strSource + '</a:CaptionElementId>\r\n' : '') +
  916.                     (fNavigationElement ? '<a:RecordNavigationElementId>Navigation' + strSource + '</a:RecordNavigationElementId>\r\n' : '') +
  917.                     '<a:DataPageSize>' + strDataPageSize + '</a:DataPageSize>\r\n' +
  918.                     '<a:GroupFilterControl/>\r\n' +
  919.                     (fAllowEdits     ? '' : '<a:NoAllowEdits/>\r\n') +
  920.                     (fAllowAdditions ? '' : '<a:NoAllowAdditions/>\r\n') +
  921.                     (fAllowDeletions ? '' : '<a:NoAllowDeletions/>\r\n') +
  922.                     (fRecordSelector ? '<a:RecordSelector/>\r\n' : '') +
  923.                 '</a:GroupLevel>\r\n';
  924.  
  925.             return strGroupLevels;
  926.             }
  927.  
  928.         function GetDefaultSort(objLevel, fAppendGroupOf, fAddChildNumber)
  929.             {
  930.             var strTemp = ""
  931.             if (objLevel.selectSingleNode("CONTROL-SOURCE[@type = 'expression']") != null)
  932.                 {
  933.                 var objReportItem = objLevel.selectSingleNode("/RPTML/REPORT[0]/SECTION/REPORT-ITEM[CONTROL-SOURCE ='" + GetNodeText(objLevel, "CONTROL-SOURCE", "") + "']");
  934.                 if (objReportItem != null)
  935.                     {
  936.                     strTemp = BracketFieldName(MungeFieldName(GetNodeText(objReportItem, "@id", "")) + (fAddChildNumber ? absoluteChildNumber(objLevel) : ""));
  937.                     }
  938.                 }
  939.             else
  940.                 strTemp = BracketFieldName(MungeFieldName(GetNodeText(objLevel, "CONTROL-SOURCE", "")) + (fAddChildNumber ? absoluteChildNumber(objLevel) : ""));
  941.  
  942.             if (fAppendGroupOf)
  943.                 strTemp = '[GroupOf' + strTemp.replace(/^\[/, '');
  944.             return strTemp;
  945.             }
  946.  
  947.         //
  948.         // Get the DataModel persistence properties
  949.         //
  950.         function GetDataModel(objElem, fComplexPage)
  951.             {
  952.             // Skip it if there is no RowSource in the DataModel
  953.             var objRowsources = objElem.selectNodes("/RPTML/REPORT[0]/DATA-MODEL/ROW-SOURCE");
  954.             if (objRowsources == null)
  955.                 return "";
  956.  
  957.             var strDatamodel = "";
  958.  
  959.             //
  960.             // Add SchemaRowsources
  961.             //
  962.  
  963.             var objRowsource;
  964.             var objFields;
  965.             var objField;
  966.             var objParams;
  967.             var objParam;
  968.             var objSource;
  969.             for (var iRowsource = 0; iRowsource < objRowsources.length; iRowsource++)
  970.                 {
  971.                 objRowsource = objRowsources.item(iRowsource);
  972.  
  973.                 // Add a SchemaRowsource for each RowSource
  974.                 strDatamodel = strDatamodel +
  975.                     '<a:SchemaRowsource ' +
  976.                         'a:id="' + CleanFormReferences(objRowsource.selectSingleNode("@id").text, objRowsource) + '" ' +
  977.                         'a:type="' + GetRowsourceType(objRowsource) + '"' +
  978.                     '>\r\n';
  979.  
  980.                 // Optionally add the command-text
  981.                 if (objRowsource.selectSingleNode("@type").text == "view" || objRowsource.selectSingleNode("@type").text == "command-text")
  982.                     strDatamodel = strDatamodel +
  983.                         '<a:CommandText>' + CleanFormReferences(objRowsource.selectSingleNode("COMMAND-TEXT").text, null) + '</a:CommandText>\r\n';
  984.  
  985.                 objFields = objRowsource.selectNodes("FIELD");
  986.                 for (var iField = 0; iField < objFields.length; iField++)
  987.                     {
  988.                     objField = objFields.item(iField);
  989.  
  990.                     // Add a SchemaField for each field in the RowSource
  991.                     strDatamodel = strDatamodel +
  992.                         '<a:SchemaField ' +
  993.                             'a:id="' + GetFieldName(objField) + '" ' +
  994.                             'a:datatype="' + objField.selectSingleNode("@datatype").text + '" ' +
  995.                             'a:size="' + objField.selectSingleNode("@size").text + '"' +
  996.                             (objField.selectSingleNode("@iskey") != null ? ' a:iskey="' + objField.selectSingleNode("@iskey").text + '"' : '') +
  997.                         '/>\r\n';
  998.                     }
  999.  
  1000.                 objParams = objRowsource.selectNodes("PARAMETER");
  1001.                 for (var iParam = 0; iParam < objParams.length; iParam++)
  1002.                     {
  1003.                     objParam = objParams.item(iParam);
  1004.  
  1005.                     // Add a SchemaParameter for each parameter in the RowSource
  1006.                     strDatamodel = strDatamodel +
  1007.                         '<a:SchemaParameter ' +
  1008.                             'a:id="' + GetFieldName(objParam) + '" ' +
  1009.                             'a:datatype="' + objParam.selectSingleNode("@datatype").text + '" ' +
  1010.                         '/>\r\n';
  1011.                     }
  1012.  
  1013.                 strDatamodel = strDatamodel + '</a:SchemaRowsource>\r\n';
  1014.                 }
  1015.  
  1016.             //
  1017.             // Add RecordsetDefs
  1018.             //
  1019.  
  1020.             for (var iRowsource = 0; iRowsource < objRowsources.length; iRowsource++)
  1021.                 {
  1022.                 objRowsource = objRowsources.item(iRowsource);
  1023.  
  1024.                 strDatamodel = strDatamodel +
  1025.                     '<a:RecordsetDef ' +
  1026.                         'a:id="' + CleanFormReferences(objRowsource.selectSingleNode("@id").text, objRowsource) + '" ' +
  1027.                     '>\r\n';
  1028.  
  1029.                 objFields = objRowsource.selectNodes("FIELD");
  1030.                 for (var iField = 0; iField < objFields.length; iField++)
  1031.                     {
  1032.                     objField = objFields.item(iField);
  1033.                     strField = GetFieldName(objField);
  1034.                     if (GetMungedFieldName(objField) != "Invalid Record Source" && strField != "Invalid Record Source")
  1035.                         {
  1036.                         strDatamodel = strDatamodel + '<a:PageField ';
  1037.                         
  1038.                         if (strField != GetMungedFieldName(objField))    // If the munged name is different, add a reference to the original field name ("a:source=")
  1039.                             strDatamodel = strDatamodel + 'a:id="' + GetMungedFieldName(objField) + '" a:source="' + strField + '"';
  1040.                         else
  1041.                             strDatamodel = strDatamodel + 'a:id="' + strField + '"';
  1042.  
  1043.                         strDatamodel = strDatamodel + '/>\r\n';
  1044.                         }
  1045.                     }
  1046.  
  1047.                 var strFieldID = "";
  1048.                 var strSource = "";
  1049.                 // If this is a ComplexPage, add expressions and group-levels
  1050.                 if (fComplexPage)
  1051.                     {
  1052.                     // Add expressions from the detail section
  1053.                     var objDetailCalcs = objElem.selectNodes("/RPTML/REPORT[0]/SECTION[@type='detail']/REPORT-ITEM[CONTROL-SOURCE/@type='expression']");
  1054.                     for (var iField = 0; iField < objDetailCalcs.length; iField++)
  1055.                         {
  1056.                         objField = objDetailCalcs.item(iField);
  1057.         
  1058.                         strFieldID = GetMungedFieldName(objField);
  1059.                         strSource  = objField.selectSingleNode("CONTROL-SOURCE").text;
  1060.  
  1061.                         strSource = strSource.replace(/nz\(/gi, 'MSODSC.NZ\(');
  1062.  
  1063.                         if (MungeFieldName(strSource) != "Invalid Record Source")
  1064.                             strDatamodel = strDatamodel + '<a:PageField a:id="' + strFieldID+ '" a:source="' + EncodeSource(strSource) + '" a:type="dscCalculated"/>\r\n';
  1065.                         }
  1066.         
  1067.                     strSource = CleanFormReferences(objElem.selectSingleNode("/RPTML/REPORT[0]/RECORD-SOURCE").text, objElem);
  1068.  
  1069.                     if (iRowsource == 0)
  1070.                         {
  1071.                         var objLevels = objElem.selectNodes("/RPTML/REPORT[0]/GROUP-LEVEL");
  1072.                         var objLevel;
  1073.                         var objGroupFields;
  1074.                         var strAttr;
  1075.                         var strTotal;
  1076.                         var strID;
  1077.                         var strNew;
  1078.                         for (var iLevel = objLevels.length-1; iLevel >= 0 ; iLevel--)
  1079.                             {
  1080.                             objLevel = objLevels.item(iLevel);
  1081.  
  1082.                             // Get the list of fields from all grouped sections
  1083.                             objGroupFields = objElem.selectNodes("/RPTML/REPORT[0]/SECTION[@idref='" + objLevel.selectSingleNode("@id").text + "']/REPORT-ITEM[CONTROL-SOURCE]");
  1084.                             if (objGroupFields.length > 0)
  1085.                                 {
  1086.                                 strDatamodel = strDatamodel + '<a:GroupingDef a:id="' + objLevel.selectSingleNode("@id").text + '">\r\n';
  1087.  
  1088.                                 // Generate the unique list of bound fields for this group-level
  1089.                                 var objList = new ActiveXObject("Scripting.Dictionary");
  1090.                                 for (var iField = 0; iField < objGroupFields.length; iField++)
  1091.                                     objList.Add(GetMungedFieldName(objGroupFields.item(iField)), "yes");
  1092.  
  1093.                                 // Walk through this field list
  1094.                                 for (var iField = 0; iField < objGroupFields.length; iField++)
  1095.                                     {
  1096.                                     objField = objGroupFields.item(iField);
  1097.  
  1098.                                     objSource = objField.selectSingleNode("CONTROL-SOURCE");
  1099.                                     strAttr = '';
  1100.  
  1101.                                     if (GetNodeText(objSource, "@type", "") == "expression")
  1102.                                         {
  1103.                                         strFieldID = GetMungedFieldName(objField);
  1104.                                         strSource  = objSource.text;
  1105.  
  1106.                                         // Is it an aggregate function?
  1107.                                         if (strSource.search(new RegExp("sum\\(|avg\\(|min\\(|max\\(|count\\(", "i")) == 0)
  1108.                                             {
  1109.                                             strTotal  = strSource.replace(/(.*)\(.*\)/i, '$1');                    // Get name of aggregate function
  1110.                                             strSource = strSource.replace(/.*\(\[*([^\]]+)\]*\)/i, '$1');        // Get name of field being aggregated
  1111.                                             strAttr   = ' a:total="dsc' + strTotal.substr(0,1).toUpperCase() + strTotal.substr(1).toLowerCase() + '"';
  1112.                                             }
  1113.                                         else
  1114.                                             {
  1115.                                             strSource = strSource.replace(/"/gi, '"');                        // Encode quotes as """
  1116.                                             for (var i = 0; i < objFields.length; i++)
  1117.                                                 {
  1118.                                                 strID = GetMungedFieldName(objFields.item(i));
  1119.                                                 strNew = strSource.replace(new RegExp("\\[(" + strID + ")\\]", "gi"), "[GroupOf$1]");
  1120.                                                 if (strNew != strSource && strID != "Invalid Record Source")    // Were there field names in the expression?
  1121.                                                     {
  1122.                                                     
  1123.                                                     var strGSBracketed = BracketFieldName('GroupOf' + strID + absoluteChildNumber(objLevel));
  1124.                                                     strSource = strSource.replace(new RegExp("\\[(" + strID + ")\\]", "gi"), "[GroupOf$1" + absoluteChildNumber(objLevel) + "]");
  1125.                                                     if (!objList.Exists(strGSBracketed))                                    // Is it one of our bound fields?
  1126.                                                         {
  1127.                                                         strDatamodel = strDatamodel + '<a:PageField a:id="' + strGSBracketed + '" a:source="' + strID + '" ' + GetGroupOnType(strID, objLevel) + '/>\r\n';
  1128.                                                         objList.Add(strGSBracketed, "yes");
  1129.                                                         }
  1130.                                                     }
  1131.                                                 }
  1132.                                             for (i = 0; i < objGroupFields.length; i++)
  1133.                                                 {
  1134.                                                 strID = GetMungedFieldName(objGroupFields.item(i));
  1135.                                                 strSource = strSource.replace(new RegExp("\\[(" + strID + ")\\]", "gi"), "[GroupOf$1" + absoluteChildNumber(objLevel) + "]");        // Munge all field references
  1136.                                                 }
  1137.                                             strAttr = ' a:type="dscCalculated"';
  1138.                                             }
  1139.                                         }
  1140.                                     else
  1141.                                         {
  1142.                                         strFieldID = MungeFieldName(objSource.text);
  1143.                                         strSource  = MungeFieldName(objSource.text);
  1144.                                         }
  1145.  
  1146.                                     // Note, strSource might not be a valid control-source at this point due to the adding of the GroupLevel index.
  1147.                                     if (strSource != "Invalid Record Source")
  1148.                                         {
  1149.                                         var strFieldIDBracketed = BracketFieldName('GroupOf' + strFieldID + absoluteChildNumber(objLevel));
  1150.                                         if (!objList.Exists(strFieldIDBracketed))
  1151.                                             {
  1152.                                             strDatamodel = strDatamodel + '<a:PageField a:id="' + strFieldIDBracketed + '" a:source="' + strSource + '" ' + GetGroupOnType(strSource, objLevel) + strAttr + '/>\r\n';
  1153.                                             objList.Add(strFieldIDBracketed, "yes")
  1154.                                             }
  1155.                                         }
  1156.                                     }
  1157.  
  1158.                                 var strGroupSource = MungeFieldName(GetNodeText(objLevel, "CONTROL-SOURCE", "Invalid Record Source")) 
  1159.                                 if (strGroupSource != "Invalid Record Source")
  1160.                                     {
  1161.                                     var strGroupSourceBracketed = GetDefaultSort(objLevel, true, true);
  1162.                                     if (!objList.Exists(strGroupSourceBracketed))
  1163.                                         {
  1164.                                         strDatamodel = strDatamodel + '<a:PageField a:id="' + strGroupSourceBracketed + '" a:source="' + strGroupSource + '" ' + GetGroupOnType(strGroupSource, objLevel) + '/>\r\n';
  1165.                                         objList.Add(strGroupSourceBracketed, "yes");
  1166.                                         }
  1167.                                     }
  1168.  
  1169.                                 strDatamodel = strDatamodel + '</a:GroupingDef>\r\n';
  1170.                                 }
  1171.                             else if (objElem.selectSingleNode("/RPTML/REPORT[0]/SECTION[@idref='" + objLevel.selectSingleNode("@id").text + "']") != null)  // no bound fields in the group level
  1172.                                 {
  1173.                                 var strGroupOf = '';
  1174.                                 
  1175.                                 strDatamodel = strDatamodel + '<a:GroupingDef a:id="' + objLevel.selectSingleNode("@id").text + '">\r\n';
  1176.                                 objSource = objLevel.selectSingleNode("CONTROL-SOURCE");
  1177.                                 strFieldID = MungeFieldName(objSource.text);
  1178.                                 
  1179.                                 if (strFieldID == "Invalid Record Source")
  1180.                                     {
  1181.                                     strGroupOf = strFieldID = objSource.text;
  1182.                                     }
  1183.                                 else
  1184.                                     {
  1185.                                     strGroupOf = 'GroupOf' + strFieldID + absoluteChildNumber(objLevel);
  1186.                                     }
  1187.                                 
  1188.                                 strDatamodel = strDatamodel + '<a:PageField a:id="' + strGroupOf + '" a:source="' + strFieldID + '" ' + GetGroupOnType(strFieldID, objLevel) + '/>\r\n';
  1189.                                 }
  1190.                             }
  1191.                         }
  1192.                     }
  1193.  
  1194.                 strDatamodel = strDatamodel + '</a:RecordsetDef>\r\n';
  1195.                 }
  1196.  
  1197.             return '<a:Datamodel a:version="0816">\r\n' + strDatamodel + '</a:Datamodel>\r\n';
  1198.             }
  1199.  
  1200.         //
  1201.         // Get the DataModel type associated with a RowSource
  1202.         //
  1203.         function GetRowsourceType(objRowsource)
  1204.             {
  1205.             if (objRowsource.selectSingleNode("PARAMETER") != null)
  1206.                 return "dscProcedure";
  1207.  
  1208.             var strType = objRowsource.selectSingleNode("@type").text
  1209.             switch (strType)
  1210.                 {
  1211.                 case "table":            return "dscTable";
  1212.                 case "view":            return "dscView";
  1213.                 case "procedure":        return "dscProcedure";
  1214.                 case "command-text":    return "dscCommandText";
  1215.                 default:                return "unknown"
  1216.                 }
  1217.             }
  1218.  
  1219.         function GetGroupOnType(strSource, objField)
  1220.             {
  1221.             if (strSource.length == 0 || objField == null || objField.selectSingleNode("GROUP-ON") == null)
  1222.                 return '';
  1223.  
  1224.             var strGroupOn = GetNodeText(objField, "GROUP-ON", "each value");
  1225.             var strGroupInterval = GetNodeText(objField, "GROUP-INTERVAL", "");
  1226.             switch (strGroupOn)
  1227.                 {
  1228.                 case "each value":            return 'a:groupon="dscEachValue"';
  1229.                 case "prefix characters":    
  1230.                     if (strGroupInterval.length > 0)
  1231.                         return 'a:groupon="dscPrefix" a:interval="' + strGroupInterval + '"';
  1232.                     else
  1233.                         return 'a:groupon="dscPrefix"';
  1234.                 case "year":                return 'a:groupon="dscYear"';
  1235.                 case "quarter":                return 'a:groupon="dscQuarter"';
  1236.                 case "month":                return 'a:groupon="dscMonth"';
  1237.                 case "week":                return 'a:groupon="dscWeek"';
  1238.                 case "day":                    return 'a:groupon="dscDay"';
  1239.                 case "hour":                return 'a:groupon="dscHour"';
  1240.                 case "minute":                return 'a:groupon="dscMinute"';
  1241.                 case "interval":            
  1242.                     if (strGroupInterval.length > 0)
  1243.                         return 'a:groupon="dscInterval" a:interval="' + strGroupInterval + '"';
  1244.                     else
  1245.                         return 'a:groupon="dscInterval"';
  1246.                 default:                    return 'a:groupon="dscEachValue"';
  1247.                 }
  1248.             }
  1249.  
  1250.         //
  1251.         // Get the name of a field. If the field has an "id" attribute, us that. Otherwise,
  1252.         // generate a unique name based on the ordinal of the field and the section it is in.
  1253.         //
  1254.         function GetFieldName(objElem)
  1255.             {
  1256.             var objID = objElem.selectSingleNode("@id");
  1257.             if (objID != null)
  1258.                 return objID.text;
  1259.             return "_Section" + absoluteChildNumber(objElem.selectSingleNode("..")) + "_Field" + absoluteChildNumber(objElem) + "_";
  1260.             }
  1261.  
  1262.         //
  1263.         // Get the munged name of a field. If the field has an "id" attribute, munge that. Otherwise,
  1264.         // generate a unique name based on the ordinal of the field and the section it is in.
  1265.         //
  1266.         function GetMungedFieldName(objElem)
  1267.             {
  1268.             var objID = objElem.selectSingleNode("@id");
  1269.             if (objID != null)
  1270.                 return MungeFieldName(objID.text);
  1271.             else
  1272.                 return CleanFormReferences("_Section" + absoluteChildNumber(objElem.selectSingleNode("..")) + "_Field" + absoluteChildNumber(objElem) + "_", null);
  1273.             }
  1274.  
  1275.         function CleanFormReferences(strSource, objElem)
  1276.             {
  1277.             if ((strSource.match(/\[Forms\]\!/i) != null) || 
  1278.                 (strSource.match(/Forms\!/i) != null) ||
  1279.                 (strSource.match(/Forms\([^\!]*\!/i) != null) ||
  1280.                 (strSource.match(/\[Reports\]\!/i) != null)  || 
  1281.                 (strSource.match(/Reports\!/i) != null) ||
  1282.                 (strSource.match(/Reports\([^\!]*\!/i) != null) ||
  1283.                 (strSource.match(/\[Form\]\!/i) != null) || 
  1284.                 (strSource.match(/Form\!/i) != null) ||
  1285.                 (strSource.match(/Form\([^\!]*\!/i) != null) ||
  1286.                 (strSource.match(/\[Report\]\!/i) != null)  || 
  1287.                 (strSource.match(/Report\!/i) != null) ||
  1288.                 (strSource.match(/Report\([^\!]*\!/i) != null))
  1289.                 return "Invalid Record Source";
  1290.  
  1291.             if (objElem != null)
  1292.                 {
  1293.                 var objRowsource = objElem.selectSingleNode("/RPTML/REPORT[0]/DATA-MODEL/ROW-SOURCE[@id='" + strSource + "']");
  1294.                 if (objRowsource == null) //if we couldn't find the rowsource, try the encoded record source
  1295.                     {
  1296.                     if (GetNodeText(objElem, "/RPTML/REPORT[0]/RECORD-SOURCE", "") == strSource)
  1297.                         {
  1298.                         var strEncodedRecordSource = GetNodeText(objElem, "/RPTML/REPORT[0]/ENCODED-RECORD-SOURCE", "");
  1299.                         if (strEncodedRecordSource != "")
  1300.                             objRowsource = objElem.selectSingleNode("/RPTML/REPORT[0]/DATA-MODEL/ROW-SOURCE[@id='" + strEncodedRecordSource + "']");
  1301.                         }
  1302.                     }
  1303.                 if (objRowsource != null && GetNodeText(objRowsource, "@type", "") == "command-text")
  1304.                     return "_dscRowsource_" + childNumber(objRowsource);
  1305.                 }
  1306.             return strSource;
  1307.             }
  1308.  
  1309.         //
  1310.         // Fixup a field name. Replaces all periods with underscores.
  1311.         //
  1312.         function MungeFieldName(strField)
  1313.             {
  1314.             return CleanFormReferences(strField.replace(/\./g, '_'), null);
  1315.             }
  1316.  
  1317.         //
  1318.         // Gets the Field name from a table.field name
  1319.         //
  1320.         function StripTableNames(strField)
  1321.             {
  1322.             return strField.replace (/.*\./, '');
  1323.             }
  1324.  
  1325.         //
  1326.         // Strips off enclosing quotes if they exist
  1327.         //
  1328.         function StripQuotes(strSource)
  1329.             {
  1330.             return strSource.replace(/^\"|\"$/g, '');
  1331.             }
  1332.  
  1333.         //
  1334.         // Encodes " as " and & as &
  1335.         //
  1336.         function EncodeSource(strSource)
  1337.             {
  1338.             var strOut = strSource.replace(/\&/g, '&');
  1339.             return strOut.replace(/\"/g, '"');
  1340.             }
  1341.  
  1342.  
  1343.         //
  1344.         // Get the id of the caption section
  1345.         //
  1346.         function GetCaptionID(objElem)
  1347.             {
  1348.             var objLevel = objElem.selectSingleNode("GROUP-LEVEL");
  1349.             if (objLevel != null)
  1350.                 return "Caption" + objLevel.selectSingleNode("@id").text;
  1351.             return "Caption" + CleanFormReferences(GetNodeText(objElem, "/RPTML/REPORT[0]/RECORD-SOURCE", ""), objElem);
  1352.             }
  1353.  
  1354.         //
  1355.         // Get the id of a group
  1356.         //
  1357.         function GetGroupID(objElem, strType)
  1358.             {
  1359.             var strID = '';
  1360.  
  1361.             switch (strType)
  1362.                 {
  1363.                 case "group_header":
  1364.                     strID = "Header" + objElem.selectSingleNode("@id").text;
  1365.                     break;
  1366.                 case "group_footer":
  1367.                     strID = "Footer" + objElem.selectSingleNode("@id").text;
  1368.                     break;
  1369.                 case "group_navigation":
  1370.                     strID = "Navigation" + objElem.selectSingleNode("@id").text;
  1371.                     break;
  1372.                 }
  1373.  
  1374.             return strID;
  1375.             }
  1376.  
  1377.         //
  1378.         // Get the id of a section
  1379.         //
  1380.         function GetSectionID(objElem, strType)
  1381.             {
  1382.             var strID = '';
  1383.  
  1384.             if (objElem.selectSingleNode("/RPTML/REPORT[0]/RECORD-SOURCE") != null)
  1385.                 {
  1386.                 switch (strType)
  1387.                     {
  1388.                     case "detail":
  1389.                         strID = "Header" + CleanFormReferences(objElem.selectSingleNode("/RPTML/REPORT[0]/RECORD-SOURCE").text, objElem);
  1390.                         break;
  1391.                     case "detail_navigation":
  1392.                         strID = "Navigation" + CleanFormReferences(objElem.selectSingleNode("/RPTML/REPORT[0]/RECORD-SOURCE").text, objElem);
  1393.                         break;
  1394.                     }
  1395.                 }
  1396.  
  1397.             return strID;
  1398.             }
  1399.  
  1400.         function IncludeNavigationBar(objElem)
  1401.             {
  1402.             return (GetNodeText(objElem, "/RPTML/REPORT[0]/NAVIGATION-SECTION", "true") == "true");
  1403.             }
  1404.  
  1405.         function IncludeNavigationSection(objElem, strType)
  1406.             {
  1407.             if (IncludeNavigationBar(objElem))
  1408.                 return true;
  1409.             return IncludeFooterSections(objElem, strType);
  1410.             }
  1411.  
  1412.         function IncludeFooterSections(objElem, strType)
  1413.             {
  1414.             if (IsDataSheetForm(objElem))
  1415.                 return false;
  1416.             
  1417.             if (GetFirstFooterSection(objElem) != null)
  1418.                 {
  1419.                 switch (strType)
  1420.                     {
  1421.                     case "detail":
  1422.                         return (GetFirstGroupLevel(objElem) == null);
  1423.                     case "group_footer":
  1424.                         return (childNumber(objElem) == objElem.selectNodes("/RPTML/REPORT[0]/GROUP-LEVEL").length);
  1425.                     }
  1426.                 }
  1427.             return false;
  1428.             }
  1429.  
  1430.         function GetFirstHeaderSection(objElem)
  1431.             {
  1432.             return objElem.selectSingleNode("/RPTML/REPORT[0]/SECTION[@type='report_header' or @type='page_header']");
  1433.             }
  1434.  
  1435.         function GetFirstFooterSection(objElem)
  1436.             {
  1437.             return objElem.selectSingleNode("/RPTML/REPORT[0]/SECTION[@type='page_footer' or @type='report_footer']");
  1438.             }
  1439.  
  1440.         function GetFirstGroupLevel(objElem)
  1441.             {
  1442.             return objElem.selectSingleNode("/RPTML/REPORT[0]/GROUP-LEVEL");
  1443.             }
  1444.  
  1445.         //
  1446.         // Get the NavBar for the detail section
  1447.         //
  1448.         function GetDetailNavBar(objElem, fIncludeDiv)
  1449.             {
  1450.             var objSection = objElem.selectSingleNode("SECTION[@type='detail']");
  1451.             if (objSection == null)
  1452.                 return "";
  1453.  
  1454.             var objRecordSource = objElem.selectSingleNode("/RPTML/REPORT[0]/RECORD-SOURCE");
  1455.             if (objRecordSource == null)
  1456.                 return "";
  1457.  
  1458.             var strSource = CleanFormReferences(objRecordSource.text, objElem);
  1459.  
  1460.             var strDivID = 'Navigation' + strSource;
  1461.             var strObjID = strSource + 'Navigation';
  1462.             
  1463.             var fRTLMode = (GetNodeText(objElem, "/RPTML/REPORT[0]/DIR") == 'right-to-left');
  1464.  
  1465.             return GetNavBar(strDivID, strObjID, strSource, 0, fIncludeDiv, fRTLMode, GetNodeText(objElem, "/RPTML/REPORT[0]/WIDTH", "6in"));            
  1466.             }
  1467.  
  1468.         //
  1469.         // Get the NavBar for a group-level section
  1470.         //
  1471.         function GetGroupNavBar(objElem, fIncludeDiv)
  1472.             {
  1473.             if (objElem.selectSingleNode("GROUP-HEADER").text != "true" && objElem.selectSingleNode("GROUP-FOOTER").text != "true")
  1474.                 return "";
  1475.  
  1476.             var objRecordSource = objElem.selectSingleNode("/RPTML/REPORT[0]/RECORD-SOURCE");
  1477.             if (objRecordSource == null)
  1478.                 return "";
  1479.  
  1480.             var strSource = objElem.selectSingleNode("@id").text;
  1481.  
  1482.             var strDivID = 'Navigation' + strSource;
  1483.             var strObjID = strSource + 'Navigation';
  1484.             
  1485.             var fRTLMode = (GetNodeText(objElem, "/RPTML/REPORT[0]/DIR") == 'right-to-left');
  1486.             
  1487.             return GetNavBar(strDivID, strObjID, strSource, 0, fIncludeDiv, fRTLMode, GetNodeText(objElem, "/RPTML/REPORT[0]/WIDTH", "6in"));            
  1488.             }
  1489.  
  1490.         //
  1491.         // Get the actual HTML element for a NavBar
  1492.         //
  1493.         function GetNavBar(strDivID, strObjID, strSource, nIndent, fIncludeDiv, fRTLMode, strWidth)
  1494.             {
  1495.             return (fIncludeDiv ? '<DIV class="Mso2dSection" id="' + strDivID + '" style="HEIGHT: 0.333in; MARGIN-LEFT: ' + nIndent * 0.25 + 'in; VISIBILITY: hidden; WIDTH: 576px; BACKGROUND-COLOR: gainsboro">\r\n' : '') +
  1496.                 '<TABLE cellPadding=0 cellSpacing=0 class=MsoNavContainer id="' + strObjID + '" style="' + (fRTLMode ? 'RIGHT' :  'LEFT') + ': 4px; POSITION: absolute; TOP: 4px; WIDTH: ' + strWidth + '"><TBODY><TR>\r\n' +
  1497.                 '<TD class=MsoNavButton style="HEIGHT: 20px; WIDTH: 20px"><IMG class=MsoNavFirst tabIndex=1 height=20 id="' + strSource + 'NavFirst" src="owc://' + (fRTLMode ? 'GIF/#11206"' :  'GIF/#11200"') + ' width=20></TD>\r\n' +
  1498.                 '<TD class=MsoNavButton style="HEIGHT: 20px; WIDTH: 20px"><IMG class=MsoNavPrevious tabIndex=2 height=20 id="' + strSource + 'NavPrevious" src="owc://' + (fRTLMode ? 'GIF/#11204"' :  'GIF/#11202"') + ' width=20></TD>\r\n' +
  1499.                 '<TD noWrap style="VERTICAL-ALIGN: middle; TEXT-ALIGN: center; WIDTH: 100%"><SPAN class=MsoNavRecordsetLabel id="' + strSource + 'NavLabel" style="VISIBILITY: hidden">' + strSource + ' |0-|1 of |2</SPAN></TD>\r\n' +
  1500.                 '<TD class=MsoNavButton style="HEIGHT: 20px; WIDTH: 20px"><IMG class=MsoNavNext tabIndex=4 height=20 id="' + strSource + 'NavNext" src="owc://' + (fRTLMode ? 'GIF/#11202"' :  'GIF/#11204"') + ' width=20></TD>\r\n' +
  1501.                 '<TD class=MsoNavButton style="HEIGHT: 20px; WIDTH: 20px"><IMG class=MsoNavLast tabIndex=5 height=20 id="' + strSource + 'NavLast" src="owc://' + (fRTLMode ? 'GIF/#11200"' :  'GIF/#11206"') + ' width=20></TD>\r\n' +
  1502.                 '<TD class=MsoNavButton style="HEIGHT: 20px; WIDTH: 20px"><IMG class=MsoNavAddNew tabIndex=6 height=20 id="' + strSource + 'NavNew" src="owc://' + (fRTLMode ? 'GIF/#11230"' :  'GIF/#11208"') + ' width=20></TD>\r\n' +
  1503.                 '<TD class=MsoNavButton style="HEIGHT: 20px; WIDTH: 20px"><IMG class=MsoNavDelete tabIndex=7 height=20 id="' + strSource + 'NavDelete" src="owc://' + (fRTLMode ? 'GIF/#11232"' :  'GIF/#11210"') + ' width=20></TD>\r\n' +
  1504.                 '<TD class=MsoNavButton style="HEIGHT: 20px; WIDTH: 20px"><IMG class=MsoNavSave tabIndex=8 height=20 id="' + strSource + 'NavSave" src="owc://GIF/#11214" width=20></TD>\r\n' +
  1505.                 '<TD class=MsoNavButton style="HEIGHT: 20px; WIDTH: 20px"><IMG class=MsoNavUndo tabIndex=9 height=20 id="' + strSource + 'NavUndo" src="owc://GIF/#11212" width=20></TD>\r\n' +
  1506.                 '<TD class=MsoNavButton style="HEIGHT: 20px; WIDTH: 20px"><IMG class=MsoNavSortAsc tabIndex=10 height=20 id="' + strSource + 'NavSortAscending" src="owc://GIF/#11216" width=20></TD>\r\n' +
  1507.                 '<TD class=MsoNavButton style="HEIGHT: 20px; WIDTH: 20px"><IMG class=MsoNavSortDesc tabIndex=11 height=20 id="' + strSource + 'NavSortDescending" src="owc://GIF/#11218" width=20></TD>\r\n' +
  1508.                 '<TD class=MsoNavButton style="HEIGHT: 20px; WIDTH: 20px"><IMG class=MsoNavFilter tabIndex=12 height=20 id="' + strSource + 'NavFilterBySelection" src="owc://GIF/#11220" width=20></TD>\r\n' +
  1509.                 '<TD class=MsoNavButton style="HEIGHT: 20px; WIDTH: 20px"><IMG class=MsoNavToggleFilter tabIndex=13 height=20 id="' + strSource + 'NavFilterToggle" src="owc://GIF/#11222" width=20></TD>\r\n' +
  1510.                 '<TD class=MsoNavButton style="HEIGHT: 20px; WIDTH: 20px"><IMG class=MsoNavHelp tabIndex=14 height=20 id="' + strSource + 'NavHelp" src="owc://GIF/#11224" width=20></TD>\r\n' +
  1511.                 '</TR></TBODY></TABLE>' +
  1512.                 (fIncludeDiv ? '\r\n</DIV>' : '');
  1513.             }
  1514.  
  1515.         var rgSharedAttr = new Array("COLOR", "BACKGROUND-COLOR", "BORDER-WIDTH", "TEXT-ALIGN",
  1516.                                       "FONT-WEIGHT", "FONT-SIZE", "FONT-FAMILY", "FONT-STYLE", "VISIBILITY", "WRITING-MODE");
  1517.  
  1518.         function GetSharedStyle(objElem)
  1519.             {
  1520.             var strStyle = GetBorderStyle(objElem);
  1521.             strStyle = GetBorderColor(objElem, strStyle);
  1522.             return AppendAttribute(strStyle, GetItemStyle(objElem, rgSharedAttr));
  1523.             }
  1524.  
  1525.         function GetDatasheetStyle(objElem)
  1526.             {
  1527.             var strStyle = "";
  1528.             var objProperty;
  1529.             
  1530.             objProperty = objElem.selectSingleNode("/RPTML/REPORT[0]/DATASHEET-FORE-COLOR");
  1531.             if (objProperty != null)
  1532.                 strStyle += "COLOR: " + objProperty.text;
  1533.  
  1534.             objProperty = objElem.selectSingleNode("/RPTML/REPORT[0]/DATASHEET-TEXT-DECORATION");    
  1535.             if (objProperty != null)
  1536.                 strStyle = AppendAttribute(strStyle, "TEXT-DECORATION: " + objProperty.text);
  1537.  
  1538.             objProperty = objElem.selectSingleNode("/RPTML/REPORT[0]/DATASHEET-FONT-STYLE");    
  1539.             if (objProperty != null)
  1540.                 strStyle = AppendAttribute(strStyle, "FONT-STYLE : " + objProperty.text);
  1541.  
  1542.             objProperty = objElem.selectSingleNode("/RPTML/REPORT[0]/DATASHEET-FONT-WEIGHT");    
  1543.             if (objProperty != null)
  1544.                 strStyle = AppendAttribute(strStyle, "FONT-WEIGHT : " + objProperty.text);
  1545.  
  1546.             objProperty = objElem.selectSingleNode("/RPTML/REPORT[0]/DATASHEET-FONT-SIZE");    
  1547.             if (objProperty != null)
  1548.                 strStyle = AppendAttribute(strStyle, "FONT-SIZE : " + objProperty.text);
  1549.  
  1550.             objProperty = objElem.selectSingleNode("/RPTML/REPORT[0]/DATASHEET-FONT-FAMILY");    
  1551.             if (objProperty != null)
  1552.                 strStyle = AppendAttribute(strStyle, "FONT-FAMILY : " + objProperty.text);
  1553.  
  1554.             return strStyle;
  1555.             }
  1556.  
  1557.         var rgSectionAttr = new Array("COLOR", "BORDER-WIDTH", "BORDER-STYLE");
  1558.         var rgSectionReportAttr = new Array("COLOR");
  1559.         var rgSectionBackgroundColorAttr = new Array("BACKGROUND-COLOR");            
  1560.  
  1561.         function GetSectionStyle(objElem)
  1562.             {
  1563.             var strStyle = "";
  1564.             if (IsReport(objElem))
  1565.                 strStyle = GetItemStyle(objElem, rgSectionReportAttr);
  1566.             else
  1567.                 strStyle = GetItemStyle(objElem, rgSectionAttr);
  1568.             strStyle = GetBorderColor(objElem, strStyle);
  1569.             if (objElem.selectSingleNode("/RPTML/REPORT[0]/BACKGROUND-IMAGE") == null)
  1570.                 strStyle = AppendAttribute(strStyle, GetItemStyle(objElem, rgSectionBackgroundColorAttr));
  1571.             strStyle = AppendAttribute(strStyle, GetSectionPosition(objElem));
  1572.             if ((GetNodeText(objElem, "@type", "") == "detail") && !IsReport(objElem) && (GetNodeText(objElem, "/RPTML/REPORT[0]/DIVIDING-LINES", "") == 'true'))
  1573.                 strStyle = AppendAttribute(strStyle, "BORDER-BOTTOM: black 1px solid");
  1574.  
  1575.             if (IsDataSheet(objElem) && GetNodeText(objElem, "@type", "") == "detail")
  1576.                 {
  1577.                 var    objProperty = objElem.selectSingleNode("/RPTML/REPORT[0]/DATASHEET-BACK-COLOR");
  1578.                 if (objProperty != null)
  1579.                     strStyle = AppendAttribute(strStyle, "BACKGROUND-COLOR: " + objProperty.text);
  1580.                 }
  1581.                 
  1582.             return strStyle;
  1583.             }
  1584.  
  1585.         function GetDetailNavigationStyle(objElem)
  1586.             {
  1587.             if (GetFirstFooterSection(objElem) != null && GetFirstGroupLevel(objElem) == null)
  1588.                 return AppendAttribute(GetSectionPosition(GetFirstFooterSection(objElem)), "POSITION: relative");
  1589.             else
  1590.                 return "HEIGHT: 0.427in; VISIBILITY: hidden; WIDTH: " + GetNodeText(objElem, "/RPTML/REPORT[0]/WIDTH", "6in");
  1591.             }
  1592.  
  1593.         function GetGroupStyle(objElem, strType)
  1594.             {
  1595.             var objSection = objElem.selectSingleNode("../SECTION[@type='" + strType + "' and @idref='" + objElem.selectSingleNode("@id").text + "']");
  1596.             if (objSection != null)
  1597.                 return GetSectionStyle(objSection);
  1598.             if (strType == "group_navigation" && IncludeNavigationBar(objElem))
  1599.                 {
  1600.                 objSection = GetFirstFooterSection(objElem);
  1601.                 if (objSection != null)
  1602.                     return GetSectionStyle(objSection);
  1603.                 else
  1604.                     return "HEIGHT: 0.427in; VISIBILITY: hidden; WIDTH: " + GetNodeText(objElem, "/RPTML/REPORT[0]/WIDTH", "6in");
  1605.                 }
  1606.             return "";
  1607.             }
  1608.  
  1609.         var rgTextAttr = new Array("COLOR", "BACKGROUND-COLOR", "TEXT-ALIGN",
  1610.                                    "FONT-WEIGHT", "FONT-SIZE", "FONT-FAMILY", "FONT-STYLE", "VISIBILITY", "Z-INDEX");
  1611.         var rgPaddingAttr = new Array("PADDING-LEFT", "PADDING-RIGHT", "PADDING-BOTTOM", "PADDING-TOP");
  1612.  
  1613.         function GetTextStyle(objElem, strType)
  1614.             {
  1615.             var strStyle = GetItemStyle(objElem, rgTextAttr);
  1616.             strStyle = AppendAttribute(strStyle, GetItemPosition(objElem, true));
  1617.             strStyle = GetOverflowStyle(objElem, strStyle);
  1618.             strStyle = GetPaddingStyle(objElem, strStyle, rgPaddingAttr);    
  1619.  
  1620.             var objParentID = objElem.selectSingleNode("@parent");
  1621.             if (objParentID != null && (objParent = objElem.selectSingleNode("../REPORT-ITEM[@id='" + objParentID.text + "']")) != null && objParent.selectSingleNode("@type").text == "check-box")
  1622.                 strStyle = AppendAttribute(strStyle, "MARGIN-LEFT: 2px; MARGIN-TOP: 2px");
  1623.  
  1624.             if (IsDataSheet(objElem))
  1625.                 {
  1626.                 if (strType == "text-box")
  1627.                     {
  1628.                     var    objProperty = objElem.selectSingleNode("/RPTML/REPORT[0]/DATASHEET-BACK-COLOR");
  1629.                     if (objProperty != null)
  1630.                         strStyle = AppendAttribute(strStyle, "BACKGROUND-COLOR: " + objProperty.text);
  1631.  
  1632.                     objProperty = objElem.selectSingleNode("/RPTML/REPORT[0]/DATASHEET-FORE-COLOR");
  1633.                     if (objProperty != null)
  1634.                         strStyle = AppendAttribute(strStyle, "COLOR: " + objProperty.text);
  1635.  
  1636.                     objProperty = objElem.selectSingleNode("/RPTML/REPORT[0]/DATASHEET-CELLS-EFFECT");
  1637.                     if (objProperty != null)
  1638.                         strStyle = AppendAttribute(strStyle, MapDataSheetBorder(objProperty));
  1639.                     }
  1640.                 if (strType == "label")
  1641.                     strStyle = AppendAttribute(strStyle, "TEXT-ALIGN: center");
  1642.                 }
  1643.  
  1644.             return AppendAttribute(strStyle, "OVERFLOW: hidden");
  1645.             }
  1646.  
  1647.         function GetBorderStyle(objElem)
  1648.             {
  1649.             var objBS = objElem.selectSingleNode("BORDER-STYLE");
  1650.  
  1651.             if (objBS != null)
  1652.                 {
  1653.                 return "BORDER-STYLE: " + MapBorderStyle(objBS);
  1654.                 }
  1655.             return "";
  1656.             }    
  1657.  
  1658.         function GetBorderColor(objElem, strStyle)
  1659.             {
  1660.             var objBC = objElem.selectSingleNode("BORDER-COLOR");
  1661.  
  1662.             if (objBC != null)
  1663.                 {
  1664.                 // If we don't have a border-color specified, then make it transparent
  1665.                 if (objBC.text != "")
  1666.                     strStyle = AppendAttribute(strStyle, "BORDER-COLOR: " + objBC.text);
  1667.                 else
  1668.                     strStyle = AppendAttribute(strStyle, "BORDER-COLOR: transparent");
  1669.                 }
  1670.             
  1671.             return strStyle;
  1672.             }
  1673.  
  1674.         var rgHyperlinkAttr = new Array("BORDER-WIDTH", "BORDER-STYLE", "TEXT-ALIGN",
  1675.                                         "FONT-WEIGHT", "FONT-SIZE", "FONT-FAMILY", "FONT-STYLE", "VISIBILITY", "Z-INDEX");
  1676.  
  1677.         function GetHyperlinkStyle(objElem)
  1678.             {
  1679.             var strStyle = GetItemStyle(objElem, rgHyperlinkAttr);
  1680.             strStyle = GetBorderColor(objElem, strStyle);
  1681.             strStyle = AppendAttribute(strStyle, GetItemPosition(objElem, true));
  1682.             strStyle = GetOverflowStyle(objElem, strStyle);
  1683.             strStyle = GetPaddingStyle(objElem, strStyle, rgPaddingAttr);    
  1684.  
  1685.             return AppendAttribute(strStyle, "OVERFLOW: hidden");
  1686.             }
  1687.  
  1688.         var rgCheckboxAttr = new Array("COLOR", "BACKGROUND-COLOR", "VISIBILITY", "Z-INDEX");
  1689.  
  1690.         function GetCheckboxStyle(objElem)
  1691.             {
  1692.             var strStyle = GetItemStyle(objElem, rgCheckboxAttr);
  1693.             strStyle = AppendAttribute(strStyle, "BORDER-STYLE: solid; BORDER-WIDTH: 0");
  1694.             return AppendAttribute(strStyle, GetItemPosition(objElem, true));
  1695.             }
  1696.  
  1697.         var rgLineAttr = new Array("COLOR", "BACKGROUND-COLOR", "BORDER-WIDTH", "BORDER-STYLE", "VISIBILITY", "Z-INDEX");
  1698.  
  1699.         function GetLineStyle(objElem)
  1700.             {
  1701.             var strStyle = GetItemStyle(objElem, rgLineAttr);
  1702.             strStyle = GetBorderColor(objElem, strStyle);
  1703.  
  1704.             var objBorder = GetStyleNode(objElem, "BORDER-WIDTH");
  1705.             if (objBorder != null)
  1706.                 {
  1707.                 var strWidth = objElem.selectSingleNode("WIDTH").text;
  1708.                 if (strWidth == "0in")
  1709.                     strWidth = objBorder.text;
  1710.  
  1711.                 var strHeight = objElem.selectSingleNode("HEIGHT").text;
  1712.                 if (strHeight == "0in")
  1713.                     strHeight = objBorder.text;
  1714.  
  1715.                 strStyle = AppendAttribute(strStyle, "WIDTH: " + strWidth);
  1716.                 strStyle = AppendAttribute(strStyle, "HEIGHT: " + strHeight);
  1717.                 }
  1718.  
  1719.             return AppendAttribute(strStyle, GetItemPosition(objElem, false));
  1720.             }
  1721.  
  1722.         var rgImageAttr = new Array("BORDER-WIDTH", "BORDER-STYLE", "VISIBILITY", "Z-INDEX");
  1723.  
  1724.         function GetImageStyle(objElem)
  1725.             {
  1726.             var strStyle = GetItemStyle(objElem, rgImageAttr);
  1727.             strStyle = GetBorderColor(objElem, strStyle);
  1728.             return AppendAttribute(strStyle, GetItemPosition(objElem, true));
  1729.             }
  1730.  
  1731.         var rgRadioButtonAttr = new Array("VISIBILITY", "Z-INDEX");
  1732.  
  1733.         function GetRadioButtonStyle(objElem)
  1734.             {
  1735.             var strStyle = GetItemStyle(objElem, rgRadioButtonAttr);
  1736.             return AppendAttribute(strStyle, GetItemPosition(objElem, true));
  1737.             }
  1738.  
  1739.         var rgBasicAttr = new Array("COLOR", "BACKGROUND-COLOR", "BORDER-WIDTH", "BORDER-STYLE", "VISIBILITY", "Z-INDEX");
  1740.  
  1741.         function GetBasicStyle(objElem)
  1742.             {
  1743.             var strStyle = GetItemStyle(objElem, rgBasicAttr);
  1744.             strStyle = GetBorderColor(objElem, strStyle);
  1745.             return AppendAttribute(strStyle, GetItemPosition(objElem, true));
  1746.             }
  1747.  
  1748.         function GetItemStyle(objElem, rgAttr)
  1749.             {
  1750.             var strStyle = "";
  1751.             var objNode;
  1752.             for (var iAttr in rgAttr)
  1753.                 {
  1754.                 objNode = objElem.selectSingleNode(rgAttr[iAttr]);
  1755.                 if (objNode != null && objNode.text != "")
  1756.                     strStyle = AppendAttribute(strStyle, rgAttr[iAttr] + ": " + objNode.text);
  1757.                 }
  1758.  
  1759.             return strStyle;
  1760.             }
  1761.  
  1762.         var rgBodyAttr = new Array("BACKGROUND-POSITION", "BACKGROUND-REPEAT");
  1763.  
  1764.         function GetBodyStyle(objElem)
  1765.             {
  1766.             var strStyle = "";
  1767.             var objImage = objElem.selectSingleNode("RPTML/REPORT[0]/BACKGROUND-IMAGE")
  1768.             if (objImage != null) 
  1769.                 {
  1770.                 strStyle = "BACKGROUND-IMAGE:url('" + objImage.text + "'); ";
  1771.                 strStyle += GetItemStyle(objElem.selectSingleNode("/RPTML/REPORT[0]"), rgBodyAttr);
  1772.                 }
  1773.  
  1774.             if (IsDataSheet(objElem))
  1775.                     strStyle = AppendAttribute(strStyle, "MARGIN: 0px");                
  1776.                     
  1777.             return strStyle;
  1778.             }            
  1779.  
  1780.         //maps the scroll style to overflow
  1781.         function GetOverflowStyle(objElem, strStyle)
  1782.             {
  1783.             var objClass = objElem.selectSingleNode("CLASS");
  1784.             if (objClass != null && objClass.text != "")
  1785.                 {
  1786.                 var objScroll = objElem.selectSingleNode("/RPTML/REPORT[0]/STYLE[@id='"+objClass.text+"']");
  1787.                 if (objScroll != null && objScroll.text != "")
  1788.                     {
  1789.                     var strScroll = GetNodeText(objScroll, "SCROLL");
  1790.                                 
  1791.                     if (strScroll == "vertical" || strScroll == "both")
  1792.                         strStyle = AppendAttribute(strStyle, "OVERFLOW-Y: scroll");
  1793.                     if (strScroll == "horizontal" || strScroll == "both")
  1794.                         strStyle = AppendAttribute(strStyle, "OVERFLOW-X: scroll");
  1795.                     }
  1796.                 }
  1797.             return strStyle;
  1798.             }
  1799.  
  1800.         //maps the padding attributes
  1801.         function GetPaddingStyle(objElem, strStyle, rgAttr)
  1802.             {
  1803.             var objClass = objElem.selectSingleNode("CLASS");
  1804.             var objNode;
  1805.             if (objClass != null && objClass.text != "")
  1806.                 {
  1807.                 var objStyle = objElem.selectSingleNode("/RPTML/REPORT[0]/STYLE[@id='"+objClass.text+"']");
  1808.                 if (objStyle != null)
  1809.                     {
  1810.                     for (var iAttr in rgAttr)
  1811.                         {
  1812.                         objNode = objStyle.selectSingleNode(rgAttr[iAttr]);
  1813.                         if (objNode != null && objNode.text != "0in")
  1814.                             strStyle = AppendAttribute(strStyle, rgAttr[iAttr] + ": " + objNode.text);
  1815.                         else
  1816.                             strStyle = AppendAttribute(strStyle, rgAttr[iAttr] + ": 1px");
  1817.                         }
  1818.                     }
  1819.                 }
  1820.             return strStyle;
  1821.             }
  1822.  
  1823.         function GetStyleNode(objElem, strName)
  1824.             {
  1825.             var objNode = objElem.selectSingleNode(strName);
  1826.             if (objNode == null)
  1827.                 objNode = objElem.selectSingleNode("/RPTML/REPORT[0]/STYLE[@id='"+objElem.selectSingleNode("CLASS").text+"']/" + strName);
  1828.             return objNode;
  1829.             }
  1830.  
  1831.         function GetItemClass(objElem, strName)
  1832.             {
  1833.             var strClass = "";
  1834.  
  1835.             // UNDONE: Need to add remaining clas types/names
  1836.             switch (strName)
  1837.                 {
  1838.                 case "label":
  1839.                     if (objElem.selectSingleNode("CONTROL-SOURCE") != null)
  1840.                         strClass = "MsoBoundSpan";
  1841.                     else
  1842.                         strClass = "MSTheme-Label";
  1843.                     break;
  1844.                 case "text":
  1845.                     strClass = "MsoTextbox";
  1846.                     break;
  1847.                 case "hyperlink":
  1848.                     strClass = "MsoHyperlinkDisplayText";
  1849.                     break;
  1850.                 case "rectangle":
  1851.                     strClass = "MsoRectangle";
  1852.                     break;
  1853.                 }
  1854.  
  1855.             if(IsDataSheet(objElem) && (strName == "label" || strName == "text"))
  1856.                 {
  1857.                 strClass += " MSODatasheetText";
  1858.                 }
  1859.             else
  1860.                 {
  1861.                 var objClass = objElem.selectSingleNode("CLASS");
  1862.                 if (objClass != null)
  1863.                     {
  1864.                     if (strClass.length > 0)
  1865.                         strClass = strClass + " ";
  1866.                     strClass = strClass + objClass.text;
  1867.                     }
  1868.                 }
  1869.  
  1870.             return strClass;
  1871.             }
  1872.  
  1873.         function IsGeneralTextAlign(objElem)
  1874.             {
  1875.             var objClass = objElem.selectSingleNode("CLASS");
  1876.             if (objClass != null)
  1877.                 {
  1878.                 objStyleNode = GetStyleNode(objElem, "TEXT-ALIGN");
  1879.                 if (objStyleNode != null && objStyleNode.text == "general")
  1880.                     return true;
  1881.                 }
  1882.             if (IsDataSheet(objElem))
  1883.                 return true;
  1884.             return false;
  1885.             }
  1886.  
  1887.         function GetSectionPosition(objElem)
  1888.             {
  1889.             if (objElem.selectSingleNode("/RPTML/REPORT[0]/LAYOUT").text == "grid" || IsDataSheetForm(objElem))
  1890.                 return GetSectionGridPosition(objElem);
  1891.             else
  1892.                 return GetSectionAbsolutePosition(objElem);
  1893.             }
  1894.  
  1895.         var rgSectionGridAttr = new Array("LEFT", "TOP");
  1896.  
  1897.         function GetSectionGridPosition(objElem)
  1898.             {
  1899.             var nWidth = 0;
  1900.  
  1901.             var fIsDataSheet = IsDataSheetForm(objElem);
  1902.             var nColumnOrder = Number(GetNodeText(objElem, "COLUMN-ORDER", "0"));
  1903.             var objHeader;
  1904.             var objColumns;
  1905.             var objColumn;
  1906.             var strSuffix;
  1907.             var strWidth;
  1908.             
  1909.             if (fIsDataSheet)
  1910.                 objHeader = objElem.selectSingleNode("/RPTML/REPORT[0]/SECTION[@type='detail']");
  1911.             else
  1912.                 objHeader = objElem.selectSingleNode("/RPTML/REPORT[0]/SECTION[@type='page_header']");
  1913.                 
  1914.             if (objHeader != null)
  1915.                 {
  1916.                 if (fIsDataSheet)
  1917.                     objColumns = objHeader.selectNodes("REPORT-ITEM[COLUMN-WIDTH]");
  1918.                 else
  1919.                     objColumns = objHeader.selectNodes("REPORT-ITEM");
  1920.                 if (objColumns.length > 0)
  1921.                     {
  1922.                     strSuffix = GetSuffix(objColumns.item(0).selectSingleNode("COLUMN-WIDTH").text);
  1923.  
  1924.                     for (var iColumn = 0; iColumn < objColumns.length; iColumn++)
  1925.                         {
  1926.                         objColumn = objColumns.item(iColumn);
  1927.                         if (objColumn.selectSingleNode("COLUMN-WIDTH") != null)
  1928.                             {
  1929.                             strWidth = objColumn.selectSingleNode("COLUMN-WIDTH").text;
  1930.                             nWidth += Number(GetBaseValue(strWidth, strSuffix));
  1931.                             }
  1932.                         else
  1933.                             nWidth += 2;        // UNDONE: Is this a good default when no column width is specified?
  1934.                         }
  1935.  
  1936.                     nWidth = String(nWidth) + strSuffix;
  1937.                     }
  1938.                 }
  1939.  
  1940.             var strPosition = "";
  1941.             strPosition = GetItemStyle(objElem, rgSectionGridAttr);
  1942.             var strHeight = GetNodeText(objElem, "/RPTML/REPORT[0]/ROW-HEIGHT", "auto");
  1943.             if (strHeight != "")
  1944.                 strPosition = AppendAttribute(strPosition, "HEIGHT: " + strHeight);
  1945.             return AppendAttribute(strPosition, "WIDTH: " + nWidth);
  1946.             }
  1947.  
  1948.         var rgSectionAbsoluteAttr = new Array("LEFT", "TOP", "WIDTH");
  1949.  
  1950.         function GetSectionAbsolutePosition(objElem)
  1951.             {
  1952.             var strHeight = objElem.selectSingleNode("HEIGHT").text;
  1953.  
  1954.             var nAdjust = 0;
  1955.             var strSuffix = GetSuffix(strHeight);
  1956.             var strSection = objElem.selectSingleNode("@type").text;
  1957.             var objBelow;
  1958.             var strAdjust = "";
  1959.  
  1960.             switch (strSection)
  1961.                 {
  1962.                 case "report_header":
  1963.                     objBelow = objElem.selectSingleNode("/RPTML/REPORT[0]/SECTION[@type='page_header']");
  1964.                     if (objBelow != null)
  1965.                         {
  1966.                         strAdjust = objBelow.selectSingleNode("HEIGHT").text;
  1967.                         nAdjust = Number(GetBaseValue(strAdjust, strSuffix));
  1968.                         }
  1969.                     break;
  1970.                 case "page_footer":
  1971.                     objBelow = objElem.selectSingleNode("/RPTML/REPORT[0]/SECTION[@type='report_footer']");
  1972.                     if (objBelow != null)
  1973.                         {
  1974.                         strAdjust = objBelow.selectSingleNode("HEIGHT").text;
  1975.                         nAdjust = Number(GetBaseValue(strAdjust, strSuffix));
  1976.                         }
  1977.                     // fall through...
  1978.                 case "report_footer":
  1979.                     if (IncludeNavigationBar(objElem))
  1980.                         nAdjust += (nAdjust == 0 ? .4 : .33);        // height needed for nav bar
  1981.                     break;
  1982.                 }
  1983.  
  1984.             if (nAdjust > 0)
  1985.                 {
  1986.                 var nHeight = Number(GetBaseValue(strHeight, strSuffix)) + nAdjust;
  1987.                 strHeight = String(nHeight) + strSuffix;
  1988.                 }
  1989.  
  1990.             var strPosition = GetItemStyle(objElem, rgSectionAbsoluteAttr);
  1991.             if (objElem.selectSingleNode("WIDTH") == null)
  1992.                 {
  1993.                 var strWidth = GetNodeText(objElem, "/RPTML/REPORT[0]/WIDTH", "6in")
  1994.                 strPosition = AppendAttribute(strPosition, "WIDTH: " + strWidth);
  1995.                 }
  1996.             return AppendAttribute(strPosition, "HEIGHT: " + strHeight);
  1997.             }
  1998.  
  1999.         function GetItemPosition(objElem, fIncludeSize)
  2000.             {
  2001.             if (objElem.selectSingleNode("/RPTML/REPORT[0]/LAYOUT").text == "grid" || IsDataSheetForm(objElem))
  2002.                 return GetItemGridPosition(objElem, fIncludeSize);
  2003.             else
  2004.                 return GetItemAbsolutePosition(objElem, fIncludeSize);
  2005.             }
  2006.  
  2007.         function GetItemGridPosition(objElem, fIncludeSize)
  2008.             {
  2009.             var nLeft = 0;
  2010.             var nWidth = 1.8;        // UNDONE: Is this a good default when no column width is specified?
  2011.             var fIsDataSheet = IsDataSheetForm(objElem);
  2012.             var nColumnOrder = Number(GetNodeText(objElem, "COLUMN-ORDER", "0"));
  2013.             var objHeader;
  2014.             var objColumns;
  2015.             var objColumn;
  2016.             var strSuffix = "";
  2017.             var nColumnTemp;
  2018.             var strWidth= "";
  2019.             
  2020.  
  2021.             if (fIsDataSheet)
  2022.                 objHeader = objElem.selectSingleNode("/RPTML/REPORT[0]/SECTION[@type='detail']");
  2023.             else
  2024.                 objHeader = objElem.selectSingleNode("/RPTML/REPORT[0]/SECTION[@type='page_header']");
  2025.  
  2026.  
  2027.             fRTLMode = (GetNodeText(objElem, "/RPTML/REPORT[0]/DIR") == 'right-to-left');
  2028.  
  2029.             if (objHeader != null)
  2030.                 {
  2031.                 if (fIsDataSheet)
  2032.                     objColumns = objHeader.selectNodes("REPORT-ITEM[COLUMN-WIDTH]");
  2033.                 else
  2034.                     objColumns = objHeader.selectNodes("REPORT-ITEM[index() < " + childNumber(objElem) + "]");
  2035.                     
  2036.                 if (objColumns.length > 0)
  2037.                     {
  2038.                     strSuffix = GetSuffix(objColumns.item(0).selectSingleNode("COLUMN-WIDTH").text);
  2039.                     var nLength = fIsDataSheet ? objColumns.length : (objColumns.length - 1);
  2040.  
  2041.                     for (var iColumn = 0; iColumn < nLength; iColumn++)
  2042.                         {
  2043.                         objColumn = objColumns.item(iColumn);
  2044.                         nColumnTemp = Number(GetNodeText(objColumn, "COLUMN-ORDER", "0"));
  2045.  
  2046.                         // for data sheets if column is to the right of current element, skip this column
  2047.                         if (!fIsDataSheet || ((nColumnOrder > nColumnTemp) || ((nColumnOrder == nColumnTemp) && childNumber(objElem) > childNumber(objColumn))))
  2048.                             {
  2049.                             if (objColumn.selectSingleNode("COLUMN-WIDTH") != null)
  2050.                                 {
  2051.                                 strWidth = objColumn.selectSingleNode("COLUMN-WIDTH").text;
  2052.                                 nLeft += Number(GetBaseValue(strWidth, strSuffix));
  2053.                                 }
  2054.                             else
  2055.                                 nLeft += 2;        // UNDONE: Is this a good default when no column width is specified?
  2056.                             }
  2057.                         }
  2058.                     nLeft = String(nLeft) + strSuffix;
  2059.                     if (fIsDataSheet)
  2060.                         nWidth = GetNodeText(objElem, "COLUMN-WIDTH", "1in");
  2061.                     else
  2062.                         nWidth = objColumns.item(objColumns.length - 1).selectSingleNode("COLUMN-WIDTH").text;
  2063.                     }
  2064.                 }
  2065.  
  2066.             var strHeight = GetNodeText(objElem, "/RPTML/REPORT[0]/ROW-HEIGHT", "1.3em");
  2067.             var strPosition = "";
  2068.  
  2069.             strPosition = AppendAttribute(strPosition, "HEIGHT: " + strHeight);
  2070.             
  2071.             return AppendAttribute(strPosition, (fRTLMode ? "RIGHT:" :  "LEFT:") + nLeft + "; WIDTH: " + nWidth + (fRTLMode ? "; TEXT-ALIGN: RIGHT" : ""));
  2072.             }
  2073.  
  2074.         var rgItemAbsoluteAttr = new Array("HEIGHT", "WIDTH");
  2075.  
  2076.         function GetItemAbsolutePosition(objElem, fIncludeSize)
  2077.             {
  2078.             var strTop  = objElem.selectSingleNode("TOP").text;
  2079.             var strLeft = objElem.selectSingleNode("LEFT").text;
  2080.  
  2081.             var nAdjust = 0;
  2082.             var strSuffix = GetSuffix(strTop);
  2083.             var strSection = objElem.selectSingleNode("../@type").text;
  2084.             var objAbove;
  2085.             var nTop;
  2086.             var objParent;
  2087.             var nTopAdjust;
  2088.             var nLeftAdjust;
  2089.  
  2090.             switch (strSection)
  2091.                 {
  2092.                 case "page_header":
  2093.                     objAbove = objElem.selectSingleNode("/RPTML/REPORT[0]/SECTION[@type='report_header']");
  2094.                     if (objAbove != null)
  2095.                         {
  2096.                         strAdjust = objAbove.selectSingleNode("HEIGHT").text;
  2097.                         nAdjust = Number(GetBaseValue(strAdjust, strSuffix));
  2098.                         }
  2099.                     break;
  2100.                 case "report_footer":
  2101.                     objAbove = objElem.selectSingleNode("/RPTML/REPORT[0]/SECTION[@type='page_footer']");
  2102.                     if (objAbove != null)
  2103.                         {
  2104.                         strAdjust = objAbove.selectSingleNode("HEIGHT").text;
  2105.                         nAdjust = Number(GetBaseValue(strAdjust, strSuffix));
  2106.                         }
  2107.                     // fall through...
  2108.                 case "page_footer":
  2109.                     if (IncludeNavigationBar(objElem))
  2110.                         nAdjust += (nAdjust == 0 ? .4 : .33);        // height needed for nav bar
  2111.                 }
  2112.  
  2113.             if (nAdjust > 0)
  2114.                 {
  2115.                 nTop = Number(GetBaseValue(strTop, strSuffix)) + nAdjust;
  2116.                 strTop = String(nTop) + strSuffix;
  2117.                 }
  2118.  
  2119.             if (objElem.selectSingleNode("@type").text == "radio-button" || 
  2120.                 objElem.selectSingleNode("@type").text == "label" || 
  2121.                 objElem.selectSingleNode("@type").text == "check-box")
  2122.                 {
  2123.                 objParent = GetParentOptionGroup(objElem)
  2124.                 if (objParent != null)
  2125.                     {
  2126.                     strSuffix = GetSuffix(objParent.selectSingleNode("TOP").text);
  2127.  
  2128.                     nTopAdjust  = Number(GetBaseValue(objParent.selectSingleNode("TOP").text,  strSuffix));
  2129.                     nLeftAdjust = Number(GetBaseValue(objParent.selectSingleNode("LEFT").text, strSuffix));
  2130.  
  2131.                     if (objElem.selectSingleNode("@type").text == "label" &&
  2132.                         (objElem.selectSingleNode("../REPORT-ITEM[@id='" + objElem.selectSingleNode("@parent").text + "']/@type").text == "radio-button" ||
  2133.                          objElem.selectSingleNode("../REPORT-ITEM[@id='" + objElem.selectSingleNode("@parent").text + "']/@type").text == "check-box"))
  2134.                         {
  2135.                         strTop = GetParent(objElem).selectSingleNode("TOP").text;        // align top of label with top of radio-button
  2136.                         nLeftAdjust -= .05;                                                // extra space required between label and radio-button
  2137.                         }
  2138.  
  2139.                     strTop  = String(Number(GetBaseValue(strTop, strSuffix))  - nTopAdjust)  + strSuffix;
  2140.                     strLeft = String(Number(GetBaseValue(strLeft, strSuffix)) - nLeftAdjust) + strSuffix;
  2141.                     }
  2142.                 }
  2143.  
  2144.             var strPosition = (fIncludeSize ? GetItemStyle(objElem, rgItemAbsoluteAttr) : '');
  2145.             return AppendAttribute(strPosition, "TOP: " + strTop + "; LEFT: " + strLeft);
  2146.             }
  2147.  
  2148.         function GetParent(objElem)
  2149.             {
  2150.             var objParentName = objElem.selectSingleNode("@parent");
  2151.             if (objParentName == null)
  2152.                 return null;
  2153.             return objElem.selectSingleNode("../REPORT-ITEM[@id='" + objParentName.text + "']");
  2154.             }
  2155.  
  2156.         function GetParentOptionGroup(objElem)
  2157.             {
  2158.             var objParentName;
  2159.             while (true)
  2160.                 {
  2161.                 objParentName = objElem.selectSingleNode("@parent");
  2162.                 if (objParentName == null)
  2163.                     break;
  2164.                 objElem = objElem.selectSingleNode("../REPORT-ITEM[@id='" + objParentName.text + "']");
  2165.                 if (objElem == null)
  2166.                     break;
  2167.                 if (objElem.selectSingleNode("@type").text == "option-group")
  2168.                     return objElem;
  2169.                 }
  2170.             return null;
  2171.             }
  2172.  
  2173.         function GetSuffix(strVal)
  2174.             {
  2175.             var cch;
  2176.             var ich;
  2177.             for (ich = strVal.length; ich > 0; ich--)
  2178.                 {
  2179.                 cch = strVal.charAt(ich - 1);
  2180.                 if ((cch >= 'a' && cch <= 'z') || (cch >= 'A' && cch <= 'Z'))
  2181.                     continue;
  2182.                 break;
  2183.                 }
  2184.             return strVal.substr(ich);
  2185.             }
  2186.  
  2187.         function GetBaseValue(strVal, strSuffix)
  2188.             {
  2189.             return strVal.substr(0, strVal.length - strSuffix.length);
  2190.             }
  2191.  
  2192.         function AppendAttribute(strList, strAttr)
  2193.             {
  2194.             if (strList.length > 0)
  2195.                 strList += "; ";
  2196.             return strList + strAttr;
  2197.             }
  2198.  
  2199.         function IncludeReportItem(objElem)
  2200.             {
  2201.             // skip all items if datasheet
  2202.             if (IsDataSheetForm(objElem))
  2203.                 return false;
  2204.             
  2205.             // We don't want to include items inside tab-pages so
  2206.             // scan the parent chain looking for a tab-page.
  2207.             var objParentName;
  2208.             while (true)
  2209.                 {
  2210.                 objParentName = objElem.selectSingleNode("@parent");
  2211.                 if (objParentName == null)
  2212.                     break;
  2213.                 objElem = objElem.selectSingleNode("../REPORT-ITEM[@id='" + objParentName.text + "']");
  2214.                 if (objElem == null)
  2215.                     break;
  2216.                 if (objElem.selectSingleNode("@type").text == "tab-page")
  2217.                     return false;
  2218.                 }
  2219.  
  2220.             // Skip items that are inside option-groups
  2221.             var objParent = GetParentOptionGroup(this);
  2222.             if (objParent != null)
  2223.                 return false;
  2224.  
  2225.             return true;
  2226.             }
  2227.  
  2228.         function IncludeControlSource(objElem)
  2229.             {
  2230.             // We want to blank out the control source
  2231.             // if controls are in report/page header/footer
  2232.             var strType = objElem.selectSingleNode("../@type").text;
  2233.             if (strType != 'report_header' && strType != 'page_header' && strType != 'page_footer' && strType != 'report_footer')
  2234.                 {
  2235.                 var strSource = GetNodeText(objElem, "CONTROL-SOURCE", "");
  2236.                 if ((strSource.match(/\[Forms\]\!/i) == null) || (strSource.match(/Forms\!/i) == null))
  2237.                     return true;
  2238.                 }
  2239.             return false;
  2240.             }
  2241.  
  2242.         function OrphanedRadioButton(objElem)
  2243.             {
  2244.             // if this radio button does not belong to an option group, return true
  2245.             var objParent = objElem.selectSingleNode("@parent");
  2246.             if ((objParent != null) && (objElem.selectSingleNode("../REPORT-ITEM[@id='" + objParent.text + "' and @type='option-group']") != null))
  2247.                 return false; //has an option group for a parent
  2248.             return true;
  2249.             }
  2250.  
  2251.         function IsReport(objElem)
  2252.             {
  2253.             if (GetNodeText(objElem, "/RPTML/REPORT[0]/OBJECT-TYPE", "") == "report")
  2254.                 return true;
  2255.             return false;
  2256.             }
  2257.  
  2258.         function IsValueList(objElem)
  2259.             {
  2260.             if (GetNodeText(objElem, "ROW-SOURCE-TYPE", "") == "Value List")
  2261.                 return true;
  2262.             return false;
  2263.             }
  2264.  
  2265.         function includeTabIndex(objElem)
  2266.             {
  2267.             if (IsReport(objElem) || objElem.selectSingleNode("TAB-INDEX") == null)
  2268.                 return false;
  2269.             return true;
  2270.             }
  2271.  
  2272.         function GetNodeText(objNode, strPath, strDefault)
  2273.             {
  2274.             var objResult = objNode.selectSingleNode(strPath);
  2275.             return (objResult != null ? objResult.text : strDefault);
  2276.             }
  2277.  
  2278.         function IsRightToLeft(objElem, strLTR, strRTL)
  2279.             {
  2280.             if (GetNodeText(objElem, "/RPTML/REPORT[0]/DIR") == 'right-to-left')
  2281.                 return strRTL;
  2282.             return strLTR;
  2283.             }
  2284.  
  2285.         function GetGroupHeaderExpando(objGroupHeader)
  2286.             {
  2287.             var strExpando = "";
  2288.             
  2289.             var objControlSource = objGroupHeader.selectSingleNode("CONTROL-SOURCE");
  2290.             if (objControlSource != null)
  2291.                 {
  2292.                 var objField = objGroupHeader.selectSingleNode("/RPTML/REPORT[0]/DATA-MODEL/ROW-SOURCE/FIELD[@id='" + objControlSource.text + "']");
  2293.                 if (objField != null)
  2294.                     {
  2295.                     strExpando = '<IMG class=MsoExpandCollapse id=';
  2296.                     strExpando += StripTableNames(GetFieldName(objField))+"Expand"; 
  2297.                     strExpando += ' src="owc://GIF/#11250" style="LEFT: 0.083in; POSITION: absolute; TOP: 0.083in; Z-INDEX: 32768" tabIndex=1>';
  2298.                     }
  2299.                 }
  2300.             
  2301.             return strExpando
  2302.             }
  2303.  
  2304.         function GetAccessKey(objCaption)
  2305.             {
  2306.             var strCaption = "";
  2307.             if (objCaption != null)
  2308.                 {
  2309.                 var objAccessKey = objCaption.selectSingleNode("../ACCESS-KEY");
  2310.                 if (objAccessKey != null)
  2311.                     {
  2312.                     strCaption = objCaption.text;
  2313.                     strCaption = strCaption.replace(new RegExp("(^[^" + objAccessKey.text + "])*" + objAccessKey.text + "(.*$)", "g"), "$1<U>" + objAccessKey.text + "</U>$2");
  2314.                     }
  2315.                 }
  2316.             return strCaption;
  2317.             }
  2318.  
  2319.         function IsDataSheetForm(objElem)
  2320.             {
  2321.             if (GetNodeText(objElem, "/RPTML/REPORT[0]/DEFAULT-VIEW", "") == "datasheet" &&
  2322.                 GetNodeText(objElem, "/RPTML/REPORT[0]/OBJECT-TYPE", "") == "form")
  2323.                 return true;
  2324.             return false;
  2325.             }
  2326.  
  2327.         function IsDataSheet(objElem)
  2328.             {
  2329.             if (GetNodeText(objElem, "/RPTML/REPORT[0]/DEFAULT-VIEW", "") == "datasheet")
  2330.                 return true;
  2331.             return false;
  2332.             }
  2333.  
  2334.         function GetColumnLabels(objElem)
  2335.             {
  2336.             var strLabels = "";
  2337.  
  2338.             var objColumns = objElem.selectNodes("/RPTML/REPORT[0]/SECTION[@type='detail']/REPORT-ITEM[COLUMN-WIDTH]");
  2339.             var objColumn;
  2340.                 
  2341.             if (objColumns.length > 0)
  2342.                 {
  2343.                 for (var iCol = 0; iCol < objColumns.length; iCol++)
  2344.                     {
  2345.                     objColumn = objColumns.item(iCol);
  2346.  
  2347.                     strLabels += GetColumnLabel(objColumn);
  2348.                     }
  2349.                 }
  2350.             return strLabels;
  2351.             }
  2352.  
  2353.         function GetColumnLabel(objColumn)
  2354.             {
  2355.             var strLabelName = GetNodeText(objColumn, "@id", "");
  2356.             var objLabel = objColumn.selectSingleNode("/RPTML/REPORT[0]/SECTION[@type='detail']/REPORT-ITEM[@parent='" + strLabelName + "']")
  2357.  
  2358.             if (objLabel != null)
  2359.                 strLabelName = GetMungedFieldName(objLabel);
  2360.             else
  2361.                 strLabelName = GetMungedFieldName(objColumn);
  2362.                 
  2363.             var strLabelHTML = "<SPAN id='" + strLabelName + "' ";
  2364.             strLabelHTML += "class='MSTheme-Label MSODatasheetText'";
  2365.             strLabelHTML += "style='" + GetItemPosition(objColumn, true) + "; OVERFLOW: hidden; POSITION: absolute; TEXT-ALIGN: center'>";
  2366.  
  2367.             var strCaption = "";
  2368.             if (objLabel != null)
  2369.                 strCaption = GetNodeText (objLabel, "CAPTION", strLabelName);
  2370.             else
  2371.                 strCaption = strLabelName;
  2372.             strCaption = strCaption.replace(/:$/, '');
  2373.                 
  2374.             strLabelHTML += strCaption + "</SPAN>";
  2375.  
  2376.             return strLabelHTML;
  2377.             }
  2378.             
  2379.         function GetColumnTextBoxes(objElem)
  2380.             {
  2381.             var strTextBoxes = "";
  2382.  
  2383.             var objColumns = objElem.selectNodes("/RPTML/REPORT[0]/SECTION[@type='detail']/REPORT-ITEM[COLUMN-WIDTH]");
  2384.             var objColumn;
  2385.  
  2386.             if (objColumns.length > 0)
  2387.                 {
  2388.                 for (var iColumn = 0; iColumn < objColumns.length; iColumn++)
  2389.                     {
  2390.                     objColumn = objColumns.item(iColumn);
  2391.  
  2392.                     strTextBoxes += GetColumnTextBox(objColumn);
  2393.                     }
  2394.                 }
  2395.             return strTextBoxes;            
  2396.  
  2397.             }
  2398.  
  2399.         function GetColumnTextBox(objColumn)
  2400.             {
  2401.             var strLabelHTML = "<TEXTAREA id='" + GetMungedFieldName(objColumn) + "' ";
  2402.             strLabelHTML += "class='MsoTextbox MSODatasheetText' MsoTextAlign='general'";
  2403.  
  2404.             var    objBackColor = objColumn.selectSingleNode("/RPTML/REPORT[0]/DATASHEET-BACK-COLOR");
  2405.             var objForeColor = objColumn.selectSingleNode("/RPTML/REPORT[0]/DATASHEET-FORE-COLOR");
  2406.             var objBorder = objColumn.selectSingleNode("/RPTML/REPORT[0]/DATASHEET-CELLS-EFFECT"); 
  2407.             strLabelHTML += "style='" + GetItemPosition(objColumn, true) + "; OVERFLOW: hidden; POSITION: absolute" + 
  2408.             ((objBackColor != null) ? ";BACKGROUND-COLOR: " + objBackColor.text: "") +
  2409.             ((objForeColor != null) ? ";COLOR: " + objForeColor.text: "") +
  2410.             ((objBorder != null) ? ";" + MapDataSheetBorder(objBorder): "") +
  2411.             "'></TEXTAREA>";
  2412.  
  2413.             return strLabelHTML;
  2414.             }
  2415.  
  2416.         function MapDataSheetBorder(objBorder)
  2417.             {
  2418.             var strBorder = "";
  2419.             var strBorderColor = GetNodeText(objBorder, "/RPTML/REPORT[0]/DATASHEET-GRIDLINES-COLOR", "#000000");
  2420.             if (objBorder != null)
  2421.                 {
  2422.                 switch(objBorder.text)
  2423.                     {
  2424.                     case "sunken":
  2425.                         return "BORDER-COLOR: " + strBorderColor + "; BORDER-STYLE:inset; BORDER-WIDTH:2px";
  2426.                     case "raised":
  2427.                         return "BORDER-STYLE:outset";
  2428.                     case "flat":
  2429.                     default:
  2430.                         var objDirection = objBorder.selectSingleNode("/RPTML/REPORT[0]/DATASHEET-GRIDLINES-BEHAVIOR");
  2431.                         var objHStyle = objBorder.selectSingleNode("/RPTML/REPORT[0]/HORIZONTAL-DATASHEET-GRIDLINE-STYLE");
  2432.                         var objVStyle = objBorder.selectSingleNode("/RPTML/REPORT[0]/VERTICAL-DATASHEET-GRIDLINE-STYLE");
  2433.                         
  2434.                         if (objDirection != null)
  2435.                             {
  2436.                             switch (objDirection.text)
  2437.                                 {
  2438.                                 case "horizontal":
  2439.                                     if (objHStyle != null)
  2440.                                         return "BORDER-BOTTOM: " + strBorderColor + " 1px " + MapBorderStyle(objHStyle) +
  2441.                                         "; BORDER-TOP: 0px; BORDER-RIGHT: 0px; BORDER-LEFT: 0px;"
  2442.                                     break;
  2443.                                 case "vertical":
  2444.                                     if (objVStyle != null)
  2445.                                         return "BORDER-RIGHT: " + strBorderColor + " 1px " + MapBorderStyle(objVStyle) + 
  2446.                                         "; BORDER-TOP: 0px; BORDER-BOTTOM: 0px; BORDER-LEFT: 0px;"
  2447.                                     break;                                
  2448.                                 case "both":
  2449.                                     if (objHStyle != null && objVStyle != null)
  2450.                                         return "BORDER-RIGHT: " + strBorderColor + " 1px " + MapBorderStyle(objVStyle) + 
  2451.                                                "; BORDER-BOTTOM: " + strBorderColor + " 1px " + MapBorderStyle(objHStyle) + 
  2452.                                                "; BORDER-TOP: 0px; BORDER-LEFT: 0px;"
  2453.                                 case "none":
  2454.                                     return "BORDER-BOTTOM: 0px; BORDER-TOP: 0px; BORDER-RIGHT: 0px; BORDER-LEFT: 0px;";
  2455.                                 default:
  2456.                                     break;
  2457.                                 }
  2458.                             }
  2459.                         return "BORDER-STYLE:solid; BORDER-WIDTH: 1px; BORDER-COLOR: " + strBorderColor + ";";
  2460.                     }
  2461.                 }
  2462.             }
  2463.  
  2464.         function MapBorderStyle(objBS)
  2465.             {
  2466.             if (objBS != null)
  2467.                 {
  2468.                 if (objBS.text == "solid" || objBS.text == "double-solid")
  2469.                     return "solid";
  2470.                 if (objBS.text == "dashed" || objBS.text == "short-dashes" || objBS.text == "dash-dot")
  2471.                     return "dashed";
  2472.                 if (objBS.text == "dotted" || objBS.text == "sparse-dots" || objBS.text == "dash-dot-dot")
  2473.                     return "dotted";
  2474.                 return objBS.text;
  2475.                 }
  2476.             return "";
  2477.             }
  2478.  
  2479.         function GetDatasheetTopBorder(objElem)
  2480.             {
  2481.             if (IsDataSheet(objElem))
  2482.                 {
  2483.                 var strBorderColor = GetNodeText(objElem, "/RPTML/REPORT[0]/DATASHEET-GRIDLINES-COLOR", "#000000");
  2484.                 return "BORDER-BOTTOM: " + strBorderColor + " 1px solid;";
  2485.                 }
  2486.             }
  2487.  
  2488.         function GetListDisplayFieldNum(objNode)
  2489.             {
  2490.             var strText = GetNodeText(objNode, "COLUMN-WIDTHS", "");
  2491.             var strTemp = strText;
  2492.             var nColumn = 0;
  2493.  
  2494.             if (strTemp == "0")
  2495.                 return 1;
  2496.  
  2497.             while (strTemp.length > 0 && strTemp != "0" && strText.match(/;/))
  2498.                 {
  2499.                 strTemp = strText.replace(/^([0-9])*;.*$/, '$1');
  2500.                 strText = strText.replace(/^[0-9]*;/, '');
  2501.                 nColumn++;
  2502.                 }
  2503.             return (strTemp == "0") ? nColumn : 0;
  2504.             }
  2505.  
  2506.         function GetLocaleFontFamily(objRoot)
  2507.             {
  2508.             objElem = objRoot.selectSingleNode("SYSTEM-SETTINGS");
  2509.             if (objElem == null)
  2510.                 {
  2511.                 strFont = "FONT-SIZE: 8pt; FONT-FAMILY: Tahoma";
  2512.                 }
  2513.             else
  2514.                 {
  2515.                 switch (objElem.nodeValue)
  2516.                     {
  2517.                     // English
  2518.                     case "1033":
  2519.                     default:
  2520.                         strFont = "FONT-SIZE: 8pt; FONT-FAMILY: Tahoma";
  2521.                         break;
  2522.  
  2523.                     // Japanese - MS P Gothic
  2524.                     case "1041":
  2525.                     case "1153":
  2526.                         strFont = "FONT-SIZE: 9pt; FONT-FAMILY:  &#EF;&#BC;&#AD;&#EF;&#BC;&#B3;&#EF;&#BC;&#B0;&#E3;R&#B4;&#E3;R&#B7;&#E3;SS&#E3;R&#AF;";
  2527.                         break;
  2528.                     
  2529.                     // Korean - Gulim
  2530.                     case "1042":
  2531.                         strFont = "FONT-SIZE: 9pt; FONT-FAMILY: &#EA;&#B5;&#B4;&#EB;&#A6;&#BC;";
  2532.                         break;
  2533.                     
  2534.                     // Traditional Chinese - New MingLi
  2535.                     case "1028":
  2536.                     case "3076":
  2537.                     case "5124":
  2538.                         strFont = "FONT-SIZE: 9pt; FONT-FAMILY: &#E6;`&#B0;&#E7;&#B4;&#B0;&#E6;bE;&#E9;&#AB;^";
  2539.                         break;
  2540.                     
  2541.                     // Simplified Chinese - Song
  2542.                     case "2052":
  2543.                     case "4100":
  2544.                         strFont = "FONT-SIZE: 9pt; FONT-FAMILY: &#E5;&#AE;B;&#E4;&#BD;]";
  2545.                         break;
  2546.                     
  2547.                     }
  2548.                 }
  2549.             
  2550.             return strFont;
  2551.             }
  2552.             
  2553.         // add brackets around field names if needed
  2554.         function BracketFieldName (strFieldName)
  2555.             {
  2556.             if (!strFieldName.match(/^\[.*\]$/))
  2557.                 return '[' + strFieldName + ']';
  2558.             return strFieldName;
  2559.             }
  2560.  
  2561.         function GetDataType(objFieldName)
  2562.             {
  2563.             if (objFieldName != null)
  2564.                 {
  2565.                 var strRecordSource = objFieldName.selectSingleNode("/RPTML/REPORT/RECORD-SOURCE").text;
  2566.                 strRecordSource = strRecordSource.replace(/^[ ]*(.+[^ ])[ ]*$/, '$1');        // remove spaces from beginning and end
  2567.                 return objFieldName.selectSingleNode("/RPTML/REPORT[0]/DATA-MODEL/ROW-SOURCE[@id='" + strRecordSource + "']/FIELD[@id='" + objFieldName.text.replace (/.*\./, '') + "']/@datatype").text;
  2568.                 }
  2569.             return 8; // string type
  2570.             }
  2571.         
  2572.     ]]></xsl:script>
  2573.  
  2574. </xsl:stylesheet>
  2575.  
  2576.